Page 1 of 1

Encrypted backups using 'duplicity' on Windows via WSL

Posted: Fri Jul 02, 2021 3:16 pm
by fips
Luckily, the Windows Subsystem for Linux (WSL) has made it really simple to use all kinds of Linux command-line tools on Windows. One of such useful tools is an open-source backup package called duplicity. It's robust, feature-rich and can be deployed and used in just a few steps, like shown below:

Given the WSL is already installed, then by typing 'bash' in the Windows Command Prompt (cmd.exe), one can enter the Linux shell, like so:

Code: Select all

C:\Users\john> bash
john@john-pc:/mnt/c/Users/john$
From there, 'duplicity' can be installed, like so:

Code: Select all

sudo apt-get install duplicity
And that's basically it, given the drives are already mounted under '/mnt/', one can backup e.g. 'c:\Users\john\data\' into 'd:\backup_john_data\', simply by typing:

Code: Select all

duplicity /mnt/c/Users/john/data/ file:///mnt/d/backup_john_data/
Which prompts for a passphrase and outputs something like this:

Code: Select all

Local and Remote metadata are synchronized, no sync needed.
Last full backup date: none
GnuPG passphrase:
Retype passphrase to confirm:
No signatures found, switching to full backup.
--------------[ Backup Statistics ]--------------
StartTime 1625233987.10 (Fri Jul  2 15:53:07 2021)
EndTime 1625233987.45 (Fri Jul  2 15:53:07 2021)
ElapsedTime 0.35 (0.35 seconds)
SourceFiles 4
SourceFileSize 8566184 (8.17 MB)
NewFiles 4
NewFileSize 8566184 (8.17 MB)
DeletedFiles 0
ChangedFiles 0
ChangedFileSize 0 (0 bytes)
ChangedDeltaSize 0 (0 bytes)
DeltaEntries 4
RawDeltaSize 8565672 (8.17 MB)
TotalDestinationSizeChange 8587856 (8.19 MB)
Errors 0
-------------------------------------------------
Similarly, restoring the backup from 'c:\backup_john_data\' back to let's say 'c:\Users\john\data_restored\', is just a matter of:

Code: Select all

duplicity restore file:///mnt/d/backup_john_data/ /mnt/c/Users/john/data_restored/
Which verifies the passphrase and outputs:

Code: Select all

Local and Remote metadata are synchronized, no sync needed.
Last full backup date: Fri Jul  2 15:53:00 2021
GnuPG passphrase:
Tip:
The '--volsize' parameter can be used to change the size of the produced backup file chunks (the default value is 25Mb, which might be rather small by modern standards, and produce a lot of files in the backup directory).

Code: Select all

duplicity --volsize 700 /mnt/c/Users/john/data/ file:///mnt/d/backup_john_data/