Automate data backup at the command line
bup
The bup (short for backup) program has been in development and maintained for seven years, and it has established itself in small IT environments owing to its speed and efficiency [2]. The software is available from the repositories for immediate installation on many major Linux distributions.
Bup already differs from other backup tools in that it uses the Git packfile format instead of traditional TAR or ZIP archives. The software is very flexible in terms of handling: For example, bup archives can be mounted as filesystems in user space. Even backing up entire ISO images, which often contain several gigabytes of data, is no problem for the software. However, using the Git packfile format does require setting up a repository first.
For an overview of the software's numerous command parameters, call the program at the prompt without any options. Bup then lists the most important parameters in short form. You can also find detailed documentation on the project site [3]. For local backups on the desktop, the program has Gtk3 and Qt-based graphical front ends, which makes the backup process easier for inexperienced users. These are available from the bup homepage.
Usage
To create a backup, you first need to initialize the backup directory using the command sequence:
BUP_DIR=/<Backup-Set> bup init
Next, index the directory to be backed up with the command:
bup index -ux /<Directory>
If no corresponding directory variable is defined, the -d
parameter must also be specified with the path for the backup set. Otherwise, bup saves the backup set in the hidden .bup
subfolder in your home directory. After indexing, perform the backup with:
bup save -n <Set-Name> /<Original-Directory>
In the event of missing directory variables, the path to the backup set must also be specified with a prefixed -d
parameter. The set name can be optionally defined and is used to identify the correct set for recovery if several backups exist on the same target media.
During the first backup run, bup creates a full backup, which can take some time depending on the original data volume. The runs that follow only create incremental backups, which is much faster.
Keep in mind that before an additional backup run you have to re-index after each change to the original content for the software to detect changes.
If you want to store the backup on a remote server, in the simplest of cases, you would enter the following command sequence:
bup save -r <Username>@<Server-IP> <Directory-Name> -n <Set-Name>/<Original-Directory>
In this case, a full backup is run for the first pass, and the subsequent backups are incremental (Figure 3).
Bup also supports backing up a remote machine to a local machine. To do this, enter the bup on
command followed by the server address and the target directory on the local system. Also, an indexing run must be performed beforehand.
To verify existing backup sets, use the bup ls
command to list the individual files. The columns give you a clear overview (Figure 4).
Reverse Gear
Restoring backups is just as easy for users: After specifying the backup set path, use the restore
parameter instead of save
, followed by the set name and the path specification. Another option here is to restore individual subdirectories from the set.
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
-
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.
-
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.