Automate data backup at the command line
Manual Trigger
An increasing number of incremental backups accumulates over time, especially if you automate the backup runs. Because these need to be restored in sequence from the last full backup, it is a very good idea to create a new full backup regularly to minimize the number of incrementally backed up archives. Duplicity launches into a full manual backup when started with the full
parameter. The incremental
parameter manually triggers an incremental backup.
If specific directories are to be excluded from the backup, you can specify these using the --exclude
parameter. Several directories that you do not want backed up can be added in a space-separated list. Excluding individual directories is useful, especially for subfolders that contain, for example, temporary, cache, or logfiles.
However, caution is required when backing up the root directory: The /proc
directory must be excluded; otherwise, Duplicity will freeze. Conversely, the --include
parameter can include additional folders in the backup.
Restore
Data recovery is just as easy: Duplicity is activated without any additional parameters; only the source and target paths need to be swapped. Alternatively, you can also specify a different target path. The archive is only unpacked after entering the passphrase, so unauthorized persons cannot access the data without knowing the password.
Using the verify
and --compare-data
parameters, you can test the integrity of your backups in a simple way. This test is possible even if the volumes are in a cloud. Particularly for documentation purposes, it is recommended to use the additional -v<x>
parameter (verbosity level), and to replace the x placeholder with one of the numbers 4, 8, or 9 to obtain meaningful information. The data can then be saved in the specified file using the --log-file <file name>
parameter.
rdiff-backup
Rdiff-backup [8] is another popular tool for backing up at the command line. The program is maintained in the repositories of virtually all major Linux distributions. The software is extremely easy to use: To produce a local backup of a directory or directory tree at the prompt, type:
rdiff-backup <Source-Directory> <Target-Directory>
This creates a full backup that the administrator can recover without special tools just as easily as using a conventional folder hierarchy, using only on-board Linux tools.
Subsequently backups made by rdiff-backup contain deleted or older versions of the changed files. The latest versions of the changed files all end up in the full backup, just like new files, so you always have the current status of the backup. Regular backups only save older versions of the database. The advantage of this special form of incremental backup, known as reverse delta, is that you do not have to fight your way through several incremental backups to restore a complete database.
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 OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.
-
Fedora 41 Released with New Features
If you're a Fedora fan or just looking for a Linux distribution to help you migrate from Windows, Fedora 41 might be just the ticket.
-
AlmaLinux OS Kitten 10 Gives Power Users a Sneak Preview
If you're looking to kick the tires of AlmaLinux's upstream version, the developers have a purrfect solution.
-
Gnome 47.1 Released with a Few Fixes
The latest release of the Gnome desktop is all about fixing a few nagging issues and not about bringing new features into the mix.
-
System76 Unveils an Ampere-Powered Thelio Desktop
If you're looking for a new desktop system for developing autonomous driving and software-defined vehicle solutions. System76 has you covered.
-
VirtualBox 7.1.4 Includes Initial Support for Linux kernel 6.12
The latest version of VirtualBox has arrived and it not only adds initial support for kernel 6.12 but another feature that will make using the virtual machine tool much easier.
-
New Slimbook EVO with Raw AMD Ryzen Power
If you're looking for serious power in a 14" ultrabook that is powered by Linux, Slimbook has just the thing for you.
-
The Gnome Foundation Struggling to Stay Afloat
The foundation behind the Gnome desktop environment is having to go through some serious belt-tightening due to continued financial problems.
-
Thousands of Linux Servers Infected with Stealth Malware Since 2021
Perfctl is capable of remaining undetected, which makes it dangerous and hard to mitigate.
-
Halcyon Creates Anti-Ransomware Protection for Linux
As more Linux systems are targeted by ransomware, Halcyon is stepping up its protection.