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
-
Red Hat Adds New Deployment Option for Enterprise Linux Platforms
Red Hat has re-imagined enterprise Linux for an AI future with Image Mode.
-
OSJH and LPI Release 2024 Open Source Pros Job Survey Results
See what open source professionals look for in a new role.
-
Proton 9.0-1 Released to Improve Gaming with Steam
The latest release of Proton 9 adds several improvements and fixes an issue that has been problematic for Linux users.
-
So Long Neofetch and Thanks for the Info
Today is a day that every Linux user who enjoys bragging about their system(s) will mourn, as Neofetch has come to an end.
-
Ubuntu 24.04 Comes with a “Flaw"
If you're thinking you might want to upgrade from your current Ubuntu release to the latest, there's something you might want to consider before doing so.
-
Canonical Releases Ubuntu 24.04
After a brief pause because of the XZ vulnerability, Ubuntu 24.04 is now available for install.
-
Linux Servers Targeted by Akira Ransomware
A group of bad actors who have already extorted $42 million have their sights set on the Linux platform.
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.