Skip to main content

Command Palette

Search for a command to run...

How to backup and restore WSL Linux

Updated
2 min read
How to backup and restore WSL Linux
H

I have over five years of experience in the IT Industry related to Network and Systems. I have responsible for focusing on Open-Source platform in the working environment. I have handled and solve the Windows & Linux Server issues.

Hi Guys အားလုံးပဲမင်္ဂလာပါခင်ဗျာ။ ဒီနေ့မှာတော့ ကျွန်တော်တို့ Windows ထဲမှာအသုံးပြုနေတဲ့ Windows Subsystem for Linux (WSL) လေးကို ဘယ်လို backup လုပ်ပြီး restore ပြန်လုပ်ရမလဲ ဆိုတာကိုပြောပြပေးမှာပဲဖြစ်ပါတယ်။ backup လုပ်ထားခြင်းဖြင့် ကျွန်တော်တို့ရဲ့ wsl linux လေးကို အကြောင်းအမျိုးမျိုးကြောင့် ဖျက်မိသွားမယ်ဆိုရင်တောင် restore ပြန်လုပ်လိုက်ခြင်းဖြင့် အရင်က backup လုပ်ခဲ့တဲ့ အခြေအနေအတိုင်း configuration တွေ file တွေကို ပြန်လည်ရရှိမှာပဲဖြစ်ပါတယ်။ wsl ကို windows terminal ကနေပဲ အလွယ်တကူ backup လုပ်လို့ရမှာဖြစ်ပါတယ်။

ပထမဆုံး အနေနဲ့ ကျွန်တော်ရဲ့ wsl linux လေးတွေ ဘယ်နှစ်ခု ရှိနေလဲဆိုတာကို စစ်ကြည့်ဖို့အတွက်

wsl -l

ဆိုတဲ့ command ကို အသုံးပြုပါမယ်။

wsl -l ဆိုပြီး စစ်လိုက်တာနဲ့ ကျွန်တော်တို့ wsl linux တွေကျလာမည်ဖြစ်ပြီးတော့ ကျွန်တော့်စက်ထဲမှာတော့ Ubuntu နဲ့ AlmaLinuxOS-9 ဆိုတဲ့ wsl linux လေး ၂ခု ရှိနေပါတယ်။ အဲ့ဒီထဲကမှ ကျွန်တော်က AlmaLinuxOS-9 ဆိုတဲ့ wsl လေးကို backup ထုတ်မှာပဲဖြစ်ပါတယ်။ backup ထုတ်မယ်ဆိုရင် အသုံးပြုရမည့် command ကတော့

wsl --export (distribution) (file path)

ပဲဖြစ်ပါတယ်။ distribution နေရာမှာ ကျွန်တော်တို့ backup လုပ်ချင်တဲ့ distribution name ကိုထည့်ရမှာဖြစ်ပြီးတော့ file path ကတော့ backup file သိမ်းမယ့် လမ်းကြောင်းကိုထည့်ခိုင်းတာဖြစ်ပါတယ်။

wsl --export AlmaLinuxOS-9 "D:\wsl\almalinux.tar"

အိုကေဒါဆို AlmaLinuxOS-9 လေးကို backup လုပ်သွားမည်ဖြစ်ပါသည်။

backup လုပ်ပြီးသွားရင်တော့ ပုံပါအတိုင်း the operation completed successfully ပြမည်ဖြစ်ပါသည်။ backup လဲလုပ်ပြီးသွားပြီဆိုတော့ AlmaLinuxOS-9 ဆိုတဲ့ wsl လေးကို unregister လုပ်လိုက်ပါမယ်။

unregister successfully ဖြစ်သွားပြီဆိုတော့အရင်ဆုံး wsl လေးကို အရင်ဆုံးဖွင့်ကြည့်လိုက်ပါမယ်။

ဒါပေမယ့် ဖွင့်လိုက်တဲ့ အချိန်မှာ wsl linux လေးမှာ unregister လုပ်ထားပြီဖြစ်တဲ့အတွက်ကြောင့် အသုံးပြုလို့ရတော့မှာ မဟုတ်တော့ပါဘူး။ အိုကေဒါဆို ကျွန်တော်တို့ wsl backup file အရင်ဆုံးသွား check လိုက်ပါမယ်။

ကျွန်တော်တို့ backup လုပ်ခဲ့တဲ့ wsl လေး ရှိတယ်ဆိုတော့ ပြန်ပြီးတော့အသုံးပြုလို့ရအောင် restore ပြန်လုပ်ပါမယ်။ restore ပြန်လုပ်ရမယ့် command ကတော့

wsl --import (Distribution) (Install Location) (File Path)

wsl linux လေးကို restore ပြန်လုပ်မယ့် အချိန်မှာတော့ install location ဆိုတယ့် လမ်းကြောင်းလေး တစ်ခုတိုးလာပဲဖြစ်ပါတယ်။ အဲ့ဒါကတော့ ကျွန်တော်တို့ wsl linux လေးကို restore လုပ်သည့် အခါ install location သတ်မှတ်ထားသည့် directory မှာ ပြန် restore လုပ်သွားမှာပဲဖြစ်ပါတယ်။ အရင်ဆုံးအနေနဲ့ ကျွန်တော်က C Partition ထဲမှာ WSL ဆိုပြီး အရင်ဆုံး directory ဆောက်လိုက်ပါမယ်။ လမ်းကြောင်းကတော့ "C:\WSL" ဒီအတိုင်းပေါ့။ အိုကေ ဒါဆို directory ဆောက်ပြီးသွားပြီ ဆိုတော့ ကျွန်တော်တို့ backup လုပ်ထားတဲ့ wsl linux ကို restore ပြန်လုပ်တော့မှာပဲ ဖြစ်ပါတယ်။

wsl --import AlmaLinuxOS-9 "C:\WSL" "D:\wsl\almalinux.tar"

ဆိုပြီးတော့ restore ပြန်လုပ်လိုက်ပါမယ်။

restore လုပ်တဲ့အချိန်ကတော့ မိမိရဲ့ wsl file size ပေါ်မူတည်ပြီးတော့ အချိန်ကြာမှာဖြစ်ပါတယ်။ restore ပြီးသွားရင် The operation completed successfully ပြမည်ဖြစ်ပါသည်။ ဒါဆိုရင်တော့ restore လုပ်သွားပြီဖြစ်သည့် အတွက် ကျွန်တော် AlmaLinuxOS-9 wsl လေးကို ပြန်ဖွင့်ကြည့်လိုက်ရအောင်။

အခုဆိုရင်တော့ ကျွန်တော်တို့ AlmaLinuxOS-9 wsl လေးကပြန်အသုံးလို့ရနေပြီဖြစ်ပြီးတော့ backup မလုပ်ခင်က သေချာအောင် hello.txt ဆိုတဲ့ file လေးဆောက်ခဲ့ပြီးမှ backup လုပ်ခဲ့တာဖြစ်ပြီးတော့ restore လုပ်သည့်အခါမှာ hello.txt ဆိုတယ့် file လေးပါပြန်ပါလာတာပဲဖြစ်ပါသည်။ ဒါကတော့ data ပြန်ရတယ်ဆိုတာကို စမ်းပြထားခြင်းပဲဖြစ်ပါတယ်။

အိုကေ ဒါဆိုရင်တော့ wsl တွေပျက်သွားတိုင်း အစကနေ config တွေပြန်ချစရာမလိုအောင် ဒီလိုမျိုး backup သိမ်းထားသင့်တယ် ဆိုတာကို ပြောပြရင်း ဒီ lab လေးကို ဒီမှာပဲ အဆုံးသတ်ချင်ပါတယ်။ အားလုံးပဲ အချိန်ပေးပြီး ဖတ်ရှုပေးတဲ့အတွက်လဲ ကျေးဇူးတင်ပါတယ် ခင်ဗျ။

43 views

More from this blog

Why need to associate IAM OIDC Provider for Amazon EKS Cluster?

Amazon EKS cluster မှာ OpenID Connect (OIDC) provider ကို associate လုပ်ရခြင်းရဲ့ အဓိကအကြောင်းရင်းကတော့ Security နဲ့ Access Control ကို ပိုမိုကောင်းမွန်အောင်ပြုလုပ်နိုင်ဖို့ဖြစ်ပါတယ်။ အဓိကအားဖြင့် အချက် (၂) ချက်ရှိပါတယ်။ To use IAM Roles for Service...

Oct 10, 20252 min read36

kubectl-like CLI tool for Amazon EKS

အားလုံးပဲမင်္ဂလာပါခင်ဗျာ။ ဒီနေ့မှာတော့ Amazon Elastic Kubernetes Service (EKS) ကို demo စမ်းဖို့အတွက် AWS ကနေမှ developed လုပ်ထားတဲ့ tool အကြောင်းကိုပြောပြမှာပဲဖြစ်ပါတယ်။ အဲ့ဒီ tool ရဲ့ nameလေးကတော့ eksdemo ပဲဖြစ်ပါတယ်။ eksdemo ဆိုတာဟာ Amazon EKS ကို...

Oct 2, 20252 min read11
kubectl-like CLI tool for Amazon EKS

Creating a cluster with kubeadm - Part 3

Part 2 မှာတော့ Cluster Setup လုပ်ဖို့အတွက် လိုအပ်တာတွေ အကုန် Installation လုပ်ပြီးဆိုတော့ ဒီမှာတော့ Cluster Setup ကို စတင်လုပ်ဆောင်တော့မှာပဲဖြစ်ပါတယ်။ Initializing your control-plane node ဒီမှာတော့ ကျွန်တော်တို့ Setup လုပ်မှာက Master Node က တစ်လုံးပဲ...

Aug 20, 20254 min read48
Creating a cluster with kubeadm - Part 3

Creating a cluster with kubeadm - Part 2

ဒီနေ့ထပ်ပြီးတော့ Sharing လုပ်မှာကတော့ kubeadm tool နဲ့ Kubernetes Cluster Setup လုပ်မှာကို ပြောပြပေးသွားမှာပဲဖြစ်ပါတယ်။ Part 1 မှာတုန်းကတော့ Kubernetes ဆိုတာဘာလဲရယ် Kubernetes Distribution အကြောင်း တွေကို အနည်းငယ်ရှင်းပြပေးခဲ့ပါတယ်။ Part 1 ကိုမဖတ်ရသေ...

Jul 23, 20255 min read49
Creating a cluster with kubeadm - Part 2
V

Vital Tech Blog

22 posts