Snalk

Snalk » OS Tutorials » Unix » Creating Incremental Backups with rdiff-backup

Reply
  #1 (permalink)  
Old 10-31-2008, 11:11 AM
Member
 
Join Date: Oct 2008
Posts: 46
Post Creating Incremental Backups with rdiff-backup

Creating Incremental Backups with rdiff-backup



Let's start with a basic script that performs backups of specified directories onto a local backup directory:

#!/bin/bash

DIRS="etc home var usr/local"
DEST="/mnt/backup"

cd /
for dir in $DIRS ; do
rdiff-backup $dir "$DEST/$(basename $dir)"
done


You can run this script as often as you like. I would suggest running it once per day. If the data is very important (like a corporate CVS repository), running it once per hour wouldn't be unreasonable.

Altering this script to back up to a remote system is as simple as changing the $DEST variable. Here is an example:

DEST="backup.mydomain.com::/mnt/backup"

This causes rdiff-backup to connect to the host backup.mydomain.com via SSH and place the backup in its directory /mnt/backup. Regardless of what system contains the backup data, it will be almost an exact mirror of the source directory. Permissions, special files, hard/soft links, and ownership will all be preserved, if possible.

The backup directory is exactly like the original, except for the additional rdiff-backup-data/ directory. This directory contains the backup logs and, most importantly, the diff files that can be used to generate older versions of files. It is very important that you do not manually change the files in the backup directory in any way. Doing so can permanently damage the backup data, probably preventing the correct recovery of any versions of the modified files.

If you are backing up the data to a remote host, you will usually want to use a directory on that system based on your system's hostname. Here is a simple example:

#!/bin/bash

DIRS="etc home var usr/local"
DEST="/mnt/backup"
shorthost='hostname | sed 's/\..*$//''

cd /
for dir in $DIRS ; do
rdiff-backup $dir "$DEST/$shorthost/$(basename $dir)"
done
Reply With Quote
Reply

Bookmarks

Tags
backup, backup with rdiff-backup, incremental backups, rdiff, unix

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump



All times are GMT. The time now is 03:59 AM.
Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.