Though your personal data is important and can be irreplaceable, few people ever think about protecting it with a backup strategy. Hard disk failures, viruses, and even accidental deletions could destroy you data forever. In order to protect my data, and in the continued belief that overkill is just enough, I do hourly backups and have 3 months of data at my fingertips. In this article I am going to cover the local backups. In a future article I will cover the remote backup strategy using a passwordless SSH

rsnapshot makes backups of local and remote systems using rsync and hard links. This means that it is possible to keep multiple, full backups is slightly larger than the space of one full backup. It is written entirely in perl and should work on any modern OS.

Since I run Slackware and there was no Slackware package, I downloaded the source and created a package using src2pkg. I changed the conf dir to /etc instead of /usr/etc.

[user@host:~]$ mkdir install
[user@host:~]$ cd install/
[user@host:~/install]$ wget http://rsnapshot.org/downloads/rsnapshot-1.3.1.tar.gz
--2011-01-12 20:39:13--  http://rsnapshot.org/downloads/rsnapshot-1.3.1.tar.gz
Resolving rsnapshot.org (rsnapshot.org)... 203.219.242.149
Connecting to rsnapshot.org (rsnapshot.org)|203.219.242.149|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 215806 (211K) [application/x-gzip]
Saving to: "rsnapshot-1.3.1.tar.gz"
[user@host:~/install]$ src2pkg -CWD -TXZ -e="--sysconfdir=/etc" rsnapshot-1.3.1.tar.gz 
Found source archive: rsnapshot-1.3.1.tar.gz
Deleting old build files - Done
Creating working directories:
   PKG_DIR=/home/user/install/rsnapshot-1.3.1-x86_64-1
   SRC_DIR=/home/user/install/rsnapshot-1.3.1-src-1
Unpacking source archive - Done
Correcting source permissions - Done
Checking for patches - None found
Found configure script - Done
Configuring sources using:
 LDFLAGS="-Wl,-L/lib64,-L/usr/lib64" CFLAGS="-O2 -fPIC -m64" ./configure --prefix=/usr --sysconfdir=/etc --libdir=/usr/lib64
Configuration has been - Successful!
   Notice - Correcting Makefile(s) with conflicting hard-coded prefix.
Compiling sources - Using: 'make'
Compiling has been - Successful!
Checking for Makefile rule: 'install' Okay
Creating content in JAIL root - Using: 'make install'
Safe content creation - Successful!
Processing package content:
chown: changing ownership of `usr/bin': Operation not permitted
Correcting package permissions - Done
Checking for standard documents - Done
Compressing man pages - Done
Creating slack-desc - From default text
Searching for links in: rsnapshot-1.3.1-x86_64-1 - None found
Rechecking package correctness -
Checking for misplaced dirs - Done
Rechecking package permissions - Done
Creating package: rsnapshot-1.3.1-x86_64-1.txz - Done
Package Creation - Successful! Package Location:
/home/user/install/rsnapshot-1.3.1-x86_64-1.txz
[user@host:~/install]$ su 
Password: 
[user@host:/home/user/install]# installpkg rsnapshot-1.3.1-x86_64-1.txz

Now we are ready to configure /etc/rsnapshot.conf. our goal is to have 24 hourly backups, 7 daily backups, 4 weekly backups, and 3 monthly backups.

[user@host ~]$ su -
Password:
[root@host ~]# cd /etc/rsnapshot/
[root@host rsnapshot]# vi /etc/rsnapshot.conf
    snapshot_root           /archive/Backup/snapshots
    retain    hourly        24
    retain    daily         7
    retain    weekly        4
    retain    monthly       3
    exclude   *~            # Do not backup backup files
    backup    /etc          host
    backup    /home         host
    backup    /opt          host
    backup    /srv          host
    backup    /usr/local    host

The important thing to note is that all the parameters are separated by tabs. This means that you do not have to escape directories that contain spaces. There are other options that you will want to set, I only covered the ones specifically related to the backup locations and files.

References
rsnapshot

Leave a Reply

You must be logged in to post a comment.