Automate data backup at the command line

Restore

To restore backed-up files from the archives, you don't need to invoke rdiff-backup again: If you need to restore your data collection from the current archive, you can simply copy the data from the backup directory. The Linux cp command helps you do this; you need to specify the archive option. The easiest form is:

cp -a /<Backup-Directory>/<File-Name> /<Restore-Directory>/<File-Name>

To access old backup files, the software offers two options: You can either access the incremental files from the rdiff-backup program, or you can use rdiff-backup-fs, which must be installed separately as an external package, to mount the backup archive as a conventional filesystem.

The rdiff-backup-fs [9] package (the name can differ among distros) is maintained in some software repositories of major Linux distributions, but it can also be picked up from the project website. For direct access, use the -r parameter (short for "restore as-of") followed by a date. For example, you need the following command sequence to restore a 10-day-old backup from a server to a local directory on a client:

rdiff-backup -r 10D <Server-Name>::/<Source-Directory>/<Restore-Directory>

The detailed documentation [10] lists various application scenarios that makes the somewhat unusual nomenclature understandable.

rsnapshot

As the name suggests, rsnapshot is a tool for creating complete snapshots of a filesystem [11]. It can create both local snapshots and use SSH to create snapshots of remote systems. The Rsync tool creates backups in which hard links replace unchanged files. Rsnapshot actually only writes modified data in the backup. The cron daemon regularly initiates the backup. Manual backup runs are not intended. The software takes all its information from a configuration file.

Because rsnapshot works with hard links, the backups always have to end up on the same filesystem. Otherwise, the tool would have to create a space-consuming full backup. Therefore, rsnapshot is more suited to servers on small networks or to local workstations than to extensive storage setups. However, the tool, which is written in Perl, only stores a configurable number of backups, so the storage space remains manageable, even with short backup intervals.

Configuration

After the installation, you need to configure the program, which is available from the repositories of practically all major Linux distributions. To do this, call the /etc/rsnapshot.conf file, which can be edited easily with any standard text editor.

Because the numerous options are easily accessible, thanks to detailed comments, the configuration does not pose unsolvable problems, even for inexperienced users. Note that the different options need to be separated by tabs. Also, path specifications must always end with a slash.

The configuration file not only lets you specify the source and target directories and list included or excluded files, it also contains a schedule for a backup plan. Moreover, settings can be defined to back up a remote server via SSH or handle an LVM network. Settings for the snapshot retention period (Figure 9) are also important.

Figure 9: rsnapshot is set up with a configuration file.

The configuration file is quite extensive, so you can validate it after a modification. To do this, enter the rsnapshot configtest command at the prompt with administrative privileges. The Syntax OK output signals a consistent configuration. A cron or anacron job then launches the software automatically. A predefined sample configuration is available in the /etc/cron.d/rsnapshot file on some distributions, and its data can be adapted to suit your individual needs. A FAQ [12] provides more information.

Buy this article as PDF

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

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
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

News