Automate data backup at the command line


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.


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).

Figure 3: With bup, data is backed up in a few steps.

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).

Figure 4: A simple display of the backed up data makes it easier for admins to check the backup.

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

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Charly's Column: Backup2l

    At his cozy home, sys admin Charly has always used rsnapshot to back up his data. Although things will be staying this way for server backups, he has found something more manageable for backing up the Kühnast family's desktop PCs.

  • Rotating Backup with rsync
  • Admin Workshop: Backups with Rsync

    It is often inefficient to fire up a tape drive whenever you need to back up files or restore a backup. The Rsync tool pushes critical files to a second computer, where you can access them easily.

  • Admin Workshop: Backups

    Data always seems to get lost at exactly the wrong moment, but the right backup strategy can help you restore those missing files.

  • Areca Backup

    Sometimes you just need to back up a few directories on a computer, not administer a distributed installation or an array of disks. Areca Backup gives you hassle-free backups of individual hard drives.

comments powered by Disqus

Direct Download

Read full article as PDF:

Price $2.95