Networking

Unix and Linux network configuration. Multiple network interfaces. Bridged NICs. High-availability network configurations.

Applications

Reviews of latest Unix and Linux software. Helpful tips for application support admins. Automating application support.

Data

Disk partitioning, filesystems, directories, and files. Volume management, logical volumes, HA filesystems. Backups and disaster recovery.

Monitoring

Distributed server monitoring. Server performance and capacity planning. Monitoring applications, network status and user activity.

Commands & Shells

Cool Unix shell commands and options. Command-line tools and application. Things every Unix sysadmin needs to know.

Home » Backups, Disaster Recovery

Backing Up WSL Images

Submitted by on October 1, 2020 – 8:13 am

Microsoft’s WSL is interesting. I’d go as far as to say that I like it. The mistake here would be to forget that your Linux image is running under Windows, with everything this entails. Making a reliable backup of this thing proved harder than I expected.

I have Acronis True Image running on my Windows 10 laptop, doing a daily backup to a NAS share. This would’ve been perfectly sufficient for restoring any Unix or Linux system. Windows is another story, however.

Simply restoring the rootfs folder of a damaged WSL Linux image doesn’t do the trick. When you launch the image following such a restore, it will tell you that it is performing an upgrade and will exit shortly thereafter without giving you any clues as to the cause of the problem.

So here’s what I ended up doing…

Install Chocolatey

Run cmd.exe as admin and copy the appropriate command string from here. It should be something like this:

@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

Install LXRunOffline:

choco install lxrunoffline

List registered images:

cd C:\tools\lxrunoffline
LxRunOffline.exe l

Export image to file:

NOTE: You may run into this error: “The process cannot access the file because it is being used by another process”. Should this happen, rebooting Windows prior to the export operation is likely to resolve the issue. I know, this sucks. But this is Windows after all…

cd C:\tools\lxrunoffline
LxRunOffline.exe e -n Ubuntu -f C:\zip\Ubuntu.tar.gz

Import image from file:

cd C:\tools\lxrunoffline
LxRunOffline.exe i -n UbuntuNew -f C:\zip\Ubuntu.tar.gz -d C:\Users\username\AppData\Local\Packages\UbuntuNew

 

Print Friendly, PDF & Email

Leave a Reply