« Previous 1 2 3 4 Next »
Backups using rdiff-backup and rsnapshot
Brothers
Using rsnapshot
The idea behind rsnapshot is clear and effective – snapshots of the data are created at specified times. Although there are no increments in rsnapshot, data is not simply copied across snapshots. Instead, the remaining files are hard linked. Hard links are a kind of reference that points to the filesystem's inode. Each file may have several such references, but it only occupies the storage space once.
In rsnapshot, you can check the use of hard links yourself as in Listing 3. The /etc/hosts
file remained unchanged in the two snapshots: hourly.2
and hourly.1
. They therefore share inode 28147. A new inode was allocated to the file in the latest backup hourly.0
because it had changed. For the data transfer itself, rsnapshot uses rsync, which synchronizes changes from A to B efficiently with its delta copy mechanism [2].
Listing 3
rsnapshot Hard Links
# ls -li hourly.*/localhost/etc/hosts 28589 -rw-r--r-- 1 root root 209 Mar 13 11:30 hourly.0/localhost/etc/hosts 28147 -rw-r--r-- 2 root root 186 Jul 10 2014 hourly.1/localhost/etc/hosts 28147 -rw-r--r-- 2 root root 186 Jul 10 2014 hourly.2/localhost/etc/hosts
Configuration
The main configuration file in rsnapshot, /etc/rsnapshot.conf
, has many configuration options – initially, you can limit the focus to the most important settings (Table 2).
Table 2
Important rsnapshot Backup Options
Option | Purpose |
---|---|
snapshot_root
|
Root directory for storing snapshots. |
no_create_root
|
If this option is 1 , rsnapshot doesn't automatically create the root directory. This is useful, for example, if mounting snapshot_root failed.
|
retain
|
The retain lines control which type of snapshot is retained for how long.
|
logfile
|
Listed commands are logged in logfile .
|
backup
|
The backup lines define the directories to be backed up. It is also possible to use a remote path (accessible via SSH).
|
cmd_ssh
|
Path to the SSH program. |
Parameters in the configuration are always separated by tab characters. You are best off running a configtest,
as follows:
# rsnapshot configtest Syntax OK
to make sure you have set everything up correctly.
Regular Snapshots
The following example shows a rsnapshot configuration for backing up the /etc
directory at hourly, daily, and weekly intervals:
retain hourly 6 retain daily 7 retain weekly 4 backup /etc/ localhost/
Using these settings, you still need to make sure rsnapshot is called regularly, because rsnapshot synchronizes and rotates data but doesn't run it regularly.
The cron service, which arranges continuous backups, is in charge of this task:
# vi /etc/cron.d/rsnapshot 0 */4 * * * root /usr/bin/rsnapshot hourly 30 3 * * * root /usr/bin/rsnapshot daily 0 3 * * 1 root /usr/bin/rsnapshot weekly
The entries shown here make sure that an "hourly backup" is performed every four hours (which means six snapshots are kept), a daily backup runs every day at 3:30am (seven snaphots are kept), and a weekly backup starts at 3:00am every Monday (four snapshots are available).
Regularly running backups using cron is equally suitable for rdiff-backup: just create a cron job that regularly ensures the rdiff-backup call.
« Previous 1 2 3 4 Next »
Buy this article as PDF
(incl. VAT)
Buy ADMIN Magazine
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Most Popular
Support Our Work
ADMIN content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.