Encrypted cloud backups with Duplicity
Safe in the Cloud
If you want to use Ubuntu One, you need an active session of X to use Duplicity, because a window appears with the password prompt. This option is thus primarily of interest to users of the Déjà Dup graphical interface. Ubuntu One sets a target folder relative to the user's home directory for the path specified in Duplicity.
If you use Amazon's S3 cloud storage (again, a free usage tier is available), you first need to create a user account, wait for your credentials, and create what is known as a bucket. Duplicity requires the name of this bucket as a path. If it is on Amazon's European availability zone (AZ), Duplicity also expects the parameters --s3-use-new-style
and --s3-european-buckets
.
To test the backup mechanism first, you can set the -v8
and -v9
switches to elicit more detailed information from Duplicity. If you will be using an SSH server or Ubuntu One for your backups, you also need the python-paramiko
package; users of S3 additionally need to install python-boto
.
The passwords are passed in as environment variables in Listing 1 and deleted again after the process. Duplicity expects FTP and SSH passwords in the FTP_PASSWORD
variable. If you prefer an unencrypted backup, you can use the --no-encryption
parameter.
Fine Tuning
If you do not want to back up all the home directories (Listing 1), you can exclude files from the backup. The parameters --include=${SOURCE}/carl
, --include=${SOURCE}/lenny
, and --exclude='**'
ensure that only the home directories belonging to carl
and Lenny
are backed up.
Duplicity also saves files in the form of volumes with a default size of 26MB. If your backup is somewhere in the gigabyte range, this action will quickly produce an impressive collection of files. You might want to change the volume size to approximately 250MB using --volsize 250
, but you should use this option with caution because it requires a huge amount of main memory.
Check It Out
In the next step, Duplicity checks to see whether the signatures of the backed up files match those of the originals. If they do not, the software displays an error message. You can evaluate this with the script here (-v
increases the verbosity level of verify
):
$ duplicity verify -v4 --s3-use-new-style --s3-european-buckets --encrypt-key ${GPG_KEY} ${AMAZON_S3} ${SOURCE}
The Duplicity user does not need to enter a GPG password here because the software typically retrieves it from .cache/duplicity
. You can output the report to a file (--log-file
), which can be mailed to you or sent by sync software in the event of an irregularity. Thus, the backup creator is always notified if a backup fails and can then take any necessary steps.
At this point, you might also consider setting up a routine that regularly checks the free or used space, or both, on the external storage and reports bottlenecks.
If you want to retrieve a specific file from the backup, you can view all of the files from the last backup:
$ duplicity list-current-files --s3-use-new-style --s3-european-buckets --encrypt-key ${GPG_KEY} {AMAZON_S3}
If you want the list to show you the state at a specific point in time, you can set the --time
parameter, which expects a time in date-time format [3] (e.g., 1997-07-16T19:20:30+01:00) or as YYYY/MM/DD.
This parameter comes into play when restoring files:
$ duplicity --time 2013/06/08 --s3-use-new-style --s3-european-buckets --file-to-restore path/to/<sourcefile> ${AMAZON_S3} path/to/<targetfolder>/<sourcefile>
Note that the --time
parameter must come before the restore command. In addition to the recovery path, you must define the name of the source file; the first path refers to the source file in the Amazon bucket.
« Previous 1 2 3 Next »
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Gnome 48 Debuts New Audio Player
To date, the audio player found within the Gnome desktop has been meh at best, but with the upcoming release that all changes.
-
Plasma 6.3 Ready for Public Beta Testing
Plasma 6.3 will ship with KDE Gear 24.12.1 and KDE Frameworks 6.10, along with some new and exciting features.
-
Budgie 10.10 Scheduled for Q1 2025 with a Surprising Desktop Update
If Budgie is your desktop environment of choice, 2025 is going to be a great year for you.
-
Firefox 134 Offers Improvements for Linux Version
Fans of Linux and Firefox rejoice, as there's a new version available that includes some handy updates.
-
Serpent OS Arrives with a New Alpha Release
After months of silence, Ikey Doherty has released a new alpha for his Serpent OS.
-
HashiCorp Cofounder Unveils Ghostty, a Linux Terminal App
Ghostty is a new Linux terminal app that's fast, feature-rich, and offers a platform-native GUI while remaining cross-platform.
-
Fedora Asahi Remix 41 Available for Apple Silicon
If you have an Apple Silicon Mac and you're hoping to install Fedora, you're in luck because the latest release supports the M1 and M2 chips.
-
Systemd Fixes Bug While Facing New Challenger in GNU Shepherd
The systemd developers have fixed a really nasty bug amid the release of the new GNU Shepherd init system.
-
AlmaLinux 10.0 Beta Released
The AlmaLinux OS Foundation has announced the availability of AlmaLinux 10.0 Beta ("Purple Lion") for all supported devices with significant changes.
-
Gnome 47.2 Now Available
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.