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.

Buy this article as PDF

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

Buy ADMIN Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Using rsync for Backups

    Although commercial Linux backup tools are available, many people prefer open source to better understand and control the backup process. One open source tool that can do both full and incremental backups is rsync.

  • Encrypted backup with Duplicity
    The free Duplicity backup program consistently encrypts all backups, which means that backups can even be stored in an insecure cloud.
  • Redo Backup
    Redo Backup backs up complete hard drives locally or over a network. The focus is on simple operation and high reliability in a variety of deployment scenarios.
  • How to back up in the cloud
    In cloud computing practice, backups are important in several ways: Customers want to secure their data, and vendors want to secure the essential details of their platforms. Rescue yourself, if you can.
  • Cloud protection with Windows Azure Backup
    Microsoft offers the Windows Azure Backup service, which lets you back up data from servers in the cloud. This removes the need for your own infrastructure, and the service alleviates privacy concerns by using continuous encryption.
comments powered by Disqus
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs



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.

Learn More”>
	</a>

<hr>		    
			</div>
		    		</div>

		<div class=