rsnapshot is a filesystem backup utility based on rsync. Using rsnapshot, it is possible to take snapshots of your filesystems at different points in time. Using hard links, rsnapshot creates the illusion of multiple full backups, while only taking up the space of one full backup plus differences. When coupled with ssh, it is possible to take snapshots of remote filesystems as well.
rsnapshot is written in Perl, and depends on rsync. OpenSSH, GNU cp, GNU du, and the BSD logger program are also recommended, but not required. rsnapshot is written with the lowest common denominator in mind. It only requires at minimum Perl 5.004 and rsync. As a result of this, it works on pretty much any UNIX-like system you care to throw at it.
rsnapshot can run almost out of the box with very little configuration changes although advanced configurations can be done with little more effort.
Install rsnapshot
rsnapshot can be installed using one of the following 1-click installs based on your openSUSE version.
openSUSE 11.0
openSUSE 10.3
openSUSE 10.2
SuSE 10.0
This should download the YaST MetaPackage file (YMP) and launch the YaST Package manager for installation. Click next on the window showing the selected repositories and next again on the package selection window and finally click Next on the installation proposal window. This should add the required repositories (click import when prompted to import the GPG Keys) and install rsnapshot and required dependencies. Click Finish when the installation is completed succesfully.
This should install rsnapshot and rsnapshot-diff under /usr/bin/.
The configuration file is rsnapshot.conf as /etc/rsnapshot.conf . Edit the configuration file using your favorite editor like “vi”
opensuse11:~ # vi /etc/rsnapshot.conf
To get you quickly started, we shall accept the defaults except the following values:
Snapshot Root directory:
You can set a directory to be the default root for all snapshots to be stored. This will be owned only by root. The permissions on this are “700” meaning no one other than the owner (root) can access the directory. The default is /.snapshots/
To change this look for the line
snapshot_root /.snapshots/
and change it to according to your needs.
Intervals
Now, look for the lines
#interval hourly 6
#interval daily 7
#interval weekly 4
#interval monthly 3
The number against the hourly/daily/weekly/monthly indicates the number of snapshots for the specified time lines. Set the number of snapshots accordingly and add/remove “#” from the lines as per your need. Let’s say we run hourly backups, everytime hourly backup is run, it creates a directory hourly.0,1,2…6 and moves the contents from hourly.0 to hourly.1 hourly.1 to hourly.2 etc. This means hourly.0 has the most recent snapshot. When a daily backup is run, hourly.5 is copied to daily.0 just keeps the chain moving up. Once, the number of snapshots for the timeline is reached (ex: hourly has reached say 6, it will remove the oldest image. Given that rsnapshot uses hardlinks unless the files changes, a snapshot for the file is made and everything else will be a hardlink.
Include/Exclude files
Include & Exclude files from the selected the filesystems using the lines
“include”
“exclude”
Backup Points
Here we choose the File systems that needs to be backed up. Look for the lines
backup /home/ localhost/
#backup /etc/ localhost/
#backup /usr/local/ localhost/
Use these to select the file systems to be backed up. For every file system to be backed up, use a seperate line. Also, remote systems can be backed up by using the above. For example,
backup root@example.com:/etc/ example.com/ exclude=mtab,exclude=core
Pre/Post scripts
You can also run custom scripts before and/or after the snapshots are taken. The lines
#cmd_preexec /path/to/preexec/script
#cmd_postexec /path/to/postexec/script
Remove the “#” command and specify the script to be run.
Save the file and we are good to go. For more options do a
opensuse11:~ # man rsnapshot
and
opensuse11:~ # man rsync
Test Configuration
Without creating any snapshots simply test the configuration as follows:
opensuse:~ # rsnapshot -t configtest
Syntax OK
Run rsnapshot
Creating a snapshot can’t be any easy than this.
To run a hourly snapshot run
opensuse11:~ # rsnapshot hourly
To run a daily snapshot
opensuse11:~ # rsnapshot daily
To run a monthly
opensuse11:~ # rsnapshot monthly
if you want to see, what it does use the “-v” switch,
opensuse:/home/saibaba/Desktop # rsnapshot -v daily
echo 11283 > /var/run/rsnapshot.pid
mv /.snapshots/daily.2/ /.snapshots/daily.3/
mv /.snapshots/daily.1/ /.snapshots/daily.2/
mv /.snapshots/daily.0/ /.snapshots/daily.1/
mkdir -m 0755 -p /.snapshots/daily.0/
/usr/bin/rsync -a –delete –numeric-ids –relative –delete-excluded \
–link-dest=/.snapshots/daily.1/localhost/ /home \
/.snapshots/daily.0/localhost/
touch /.snapshots/daily.0/
rm -f /var/run/rsnapshot.pid
You can see the snapshots in the root directory:
opensuse:/.snapshots # ls -l
total 28
drwxr-xr-x 3 root root 4096 Oct 4 22:09 daily.0
drwxr-xr-x 3 root root 4096 Oct 4 20:33 daily.1
drwxr-xr-x 3 root root 4096 Oct 4 20:18 daily.2
drwxr-xr-x 3 root root 4096 Oct 4 20:15 daily.3
drwxr-xr-x 3 root root 4096 Oct 4 20:05 hourly.0
drwxr-xr-x 3 root root 4096 Oct 4 20:03 hourly.1
drwxr-xr-x 3 root root 4096 Oct 4 20:02 hourly.2
To check the disk space usage
opensuse:/.snapshots # rsnapshot du localhost/home/
152M /.snapshots/daily.0/localhost/home/
75M /.snapshots/daily.1/localhost/home/
9.7M /.snapshots/daily.2/localhost/home/
9.6M /.snapshots/daily.3/localhost/home/
246M total
Restore Data
Restoring data is failry straight forward as the files are available under the snapshot root. The one thing to remember is that only “root” owns the directory and no one else can access the files. You need to restore files as root.
While this is understandable as a measure of security, in instances where there is a requirement to allow users to restore there files, it can be done as either mounting the snapshoot root as NFS share or a SAMBA share as a Read-Only file system.
rsnapshot is simple and very effective to use. Click here for more information from the project homepage.
is there a way to encrypt?
I’m afraid no…
You can backup to an encrypted partition, using the pre and post scripts it could only be mounted on demand.
the sofware for 10.2 is not downloadable