Backup Procedure Using WSL
Using Microsoft Windows Subsystem for Linux (WSL) to gain access to Linux command line tools within Microsoft Windows 10, I was able to create a consistent backup procedure that can be performed in Windows and Linux environments. I used SyncToy and File Checksum Integrity Verifier (FCIV) to perform backups before adopting this standard approach.
Except where noted, the following procedure can be performed in both Windows and Linux environments.
- Navigate to Desired Folder’s Parent.
$ cd /mnt/c/myfolderparent
- Generate SHA1 Digest File.
$ find ./myfolder -type f -exec sha1sum -b "{}" + > ~/myfolder.sha1
- Verify SHA1 Digest File (optional).
$ sha1sum -c ~/myfolder.sha1
or
$ sha1sum -c --quiet ~/myfolder.sha1
Note: myfolder.sha1 contains relative paths. The above command requires execution from a directory where relative paths lead to the files desired for integrity checks.
- Mount Destination (optional)
- Create Mount Point
$ mkdir /mnt/usbdrive
- Review Mount Options of Mounted Fixed Drives
$ mount
- Mount Drive
$ sudo mount -t drvfs f: /mnt/usbdrive \ -o noatime,uid=1000,gid=1000
This command is specific to Microsoft Windows; a similar command is available in the Linux environment. “f:” is the drive letter that Microsoft Windows assigned to the inserted USB drive in this example. Options are specified to match those highlighted above for the already mounted fixed drives.
- Create Mount Point
- Perform Copy
- Dry Run
$ rsync -n -av --delete --force --progress \ --human-readable ./myfolder/ /mnt/usbdrive/myfolder
- Live Run
$ rsync -av --delete --force --progress \ --human-readable ./myfolder/ /mnt/usbdrive/myfolder
The trailing ‘/’ of the source folder is important to the command’s correctness.
- Dry Run
- Move Checksum File
$ cp ~/myfolder.sha1 /mnt/usbdrive/.
- Verify File Integrity
$ cd /mnt/usbdrive $ sha1sum -c myfolder.sha1