Automate data backup at the command line
Extras
Bup provides some little extras to check the integrity of backup sets. One of the most important goodies in practice is probably the option to mount a backup in user space like a conventional drive. The python-fuse package must be installed, and a mount directory must be created. The set is then integrated into the existing system by using:
bup -d <Path_to_Backupset> fuse <Target-Directory>
You can then proceed to use the target directory and its content like any conventional drive.
Duplicity
Duplicity [4], which is available as a binary package for almost all common Linux distributions, is very flexible in terms of supported storage locations. Not only can you save backups locally, but also on FTP or SSH servers in the intranet. Additionally, Duplicity supports Windows shares and WebDAV storage.
If such central storage options are not available, Duplicity can store the backups in the cloud. For this option, it supports Amazon's S3 cloud and Rackspace cloud solutions. One of the unique selling points of Duplicity is encryption: All files can be encrypted with GnuPG (GPG) and stored safely in a cloud, without curious outsiders being able to view them.
The software takes a very professional approach to creating backups: The first pass is a full backup, which it bundles into a TAR archive. The program then uses incremental backups, which saves not only storage space, but also time – in particular for larger databases. Signatures ensure data integrity, even in insecure environments.
That said, Duplicity does require a fair amount of user training because of its very complicated parameters [5]. Alternatively, graphical front ends (e.g., Déjà Dup [6]) that operate more intuitively are recommended, especially in smaller environments or for desktop backups, even though they fall well short of reproducing Duplicity's full functionality. The software does not support differential backups.
Duplicity is suitable for backing up individual folders, but not for creating complete system images. (Programs like Clonezilla [7] are better suited to this purpose.) In doing so, the program stores the backed-up data in volumes. For local backups, you also need to specify the absolute path, so the data is stored in the correct target folder.
Key Service
To let Duplicity play to its strengths (encrypted backups), you first have to generate a GPG key or already be in possession of one. Entering gpg --gen-key
at the prompt generates a new key in just a few steps, and you can also define the key strength (Figure 5).
The passphrase you specify when generating a key also provides increased security: If the key is lost, third parties cannot simply decrypt the archive because the passphrase is requested when restoring the database. Particularly paranoid users can also digitally sign their archives so that the data integrity of the backup volumes can be checked at a later time.
In the simplest case, specify the following command for a local backup:
duplicity /<Source-Directory> file://<Target-Directory>
After prompting you for the passphrase twice, the software creates the backup in the target directory.
To save data on an FTP server, call the software using the command:
duplicity /<Source-Directory> ftp://<backupuser>@<Host.Name>/<Target-Directory>
The passphrase is also requested here before saving; you can work around the prompt by prefixing the sequence FTP_PASSWORD=<Password>
to the backup command. In both cases, Duplicity automatically checks to see whether a full backup already exists in the target path. If this is not the case, it automatically creates the full backup during the first pass. With the second pass, it creates an incremental backup (Figure 6).
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
-
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.
-
Kodi 21.0 Open-Source Entertainment Hub Released
After a year of development, the award-winning Kodi cross-platform, media center software is now available with many new additions and improvements.
-
Linux Usage Increases in Two Key Areas
If market share is your thing, you'll be happy to know that Linux is on the rise in two areas that, if they keep climbing, could have serious meaning for Linux's future.
-
Vulnerability Discovered in xz Libraries
An urgent alert for Fedora 40 has been posted and users should pay attention.
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.