For minimum installation you'll need perl (9.7M), rsync (222K), gawk (327K) and rsnapshot 1.3 (191K).
I recomment to use the following repository for ipkg
Code:
http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable
Run the following script in shell (can take time while perl is downloaded - about 5 mins at 2200kbps for everything)
Code:
ipkg update
ipkg install rsync
ipkg install gawk
ipkg install perl
mkdir /tmp/harddisk/rsnapshot
cd /tmp/harddisk/rsnapshot
wget http://www.rsnapshot.org/downloads/rsnapshot-1.3.0.tar.gz
tar -xzvf rsnapshot-1.3.0.tar.gz
cd rsnapshot-1.3.0
./configure --sysconfdir=/opt/etc --prefix=/opt --bindir=/opt/bin --mandir=/opt/man --with-perl=/opt/bin/perl --with-rsync=/opt/bin/rsync
make test
make install
#cp /opt/etc/rsnapshot.conf.default /opt/etc/rsnapshot.conf
mkdir /tmp/harddisk/backups
Open /opt/etc/rsnapshot.conf with your favourite editor
Important!!!
1. Between variable_name and variable_value must be a tabulation, not spaces
2. Path to dir must end with slash "/"
Right: /tmp/harddisk/opt/
Wrong: /tmp/harddisk/opt
Change standard values with the following
старая строка > новая строка
snapshot_root /.snapshots/ > snapshot_root /tmp/harddisk/backups/
#cmd_ssh /usr/bin/ssh > cmd_ssh /usr/bin/ssh
cmd_logger /usr/bin/logger > #cmd_logger /usr/bin/logger
#cmd_du /usr/bin/du > cmd_du /usr/bin/du
#cmd_rsnapshot_diff /usr/local/bin/rsnapshot-diff > cmd_rsnapshot_diff /opt/bin/rsnapshot-diff
interval hourly 6 > interval hourly 24
#logfile /var/log/rsnapshot > logfile /opt/var/log/rsnapshot.log
#du_args -csh > du_args -csH
In this section set up rules for exclusions and backups (my example)
exclude *.tmp
exclude *.avi
exclude /~*
exclude /private/*
###############################
### BACKUP POINTS / SCRIPTS ###
###############################
backup /opt/bin/ asus/
backup /usr/ asus/
Save changes and exit.
Run
Code:
rsnapshot configtest
Answer should be Run program in test mode
Code:
rsnapshot -t hourly
Answer should be
echo 25893 > /var/run/rsnapshot.pid
mkdir -m 0755 -p /tmp/harddisk/backups/hourly.0/
/opt/bin/rsync -a --delete --numeric-ids --relative --delete-excluded /opt \
/tmp/harddisk/backups/hourly.0/opt/
mkdir -m 0755 -p /tmp/harddisk/backups/hourly.0/
/opt/bin/rsync -a --delete --numeric-ids --relative --delete-excluded /usr \
/tmp/harddisk/backups/hourly.0/usr/
mkdir -m 0755 -p /tmp/harddisk/backups/hourly.0/
/opt/bin/rsync -a --delete --numeric-ids --relative --delete-excluded \
/tmp/harddisk/exchange /tmp/harddisk/backups/hourly.0/exchange/
touch /tmp/harddisk/backups/hourly.0/
Create a test script, run it (it takes a while) and look what you get
Code:
echo "#!/bin/sh" >> /opt/tmp/test.sh
echo "rsnapshot hourly" >> /opt/tmp/test.sh
chmod +x /opt/tmp/test.sh
/opt/tmp/test.sh
ls -l /tmp/harddisk/backups
In /tmp/harddisk/backups should appear folder hourly.0
drwxr-xr-x 3 admin root 4096 Oct 27 19:11 .
drwxr-xr-x 11 admin root 4096 Oct 27 18:07 ..
drwxr-xr-x 3 admin root 4096 Oct 27 19:12 hourly.0
Now take a look what was logged
Code:
cat /opt/var/log/rsnapshot.log
Answer should be
[27/Oct/2007:19:11:53] /opt/bin/rsnapshot hourly: started
[27/Oct/2007:19:11:53] echo 30847 > /var/run/rsnapshot.pid
[27/Oct/2007:19:11:53] mkdir -m 0755 -p /tmp/harddisk/backups/hourly.0/
[27/Oct/2007:19:11:53] /opt/bin/rsync -a --delete --numeric-ids --relative --delete-excluded /opt/bin /tmp/harddisk/backups/hourly.0/asus/
[27/Oct/2007:19:12:22] /opt/bin/rsync -a --delete --numeric-ids --relative --delete-excluded /usr /tmp/harddisk/backups/hourly.0/asus/
[27/Oct/2007:19:12:31] touch /tmp/harddisk/backups/hourly.0/
[27/Oct/2007:19:12:31] rm -f /var/run/rsnapshot.pid
[27/Oct/2007:19:12:31] /opt/bin/rsnapshot hourly: completed successfully
If folders already existed answer would be
[27/Oct/2007:19:06:08] /opt/bin/rsnapshot hourly: started
[27/Oct/2007:19:06:08] echo 30726 > /var/run/rsnapshot.pid
[27/Oct/2007:19:06:08] mv /tmp/harddisk/backups/hourly.4/ /tmp/harddisk/backups/hourly.5/
[27/Oct/2007:19:06:08] mv /tmp/harddisk/backups/hourly.3/ /tmp/harddisk/backups/hourly.4/
[27/Oct/2007:19:06:08] mv /tmp/harddisk/backups/hourly.2/ /tmp/harddisk/backups/hourly.3/
[27/Oct/2007:19:06:08] mv /tmp/harddisk/backups/hourly.1/ /tmp/harddisk/backups/hourly.2/
[27/Oct/2007:19:06:08] native_cp_al("/tmp/harddisk/backups/hourly.0", "/tmp/harddisk/backups/hourly.1")
[27/Oct/2007:19:06:10] /opt/bin/rsync -a --delete --numeric-ids /tmp/harddisk/backups/hourly.0/ /tmp/harddisk/backups/hourly.1/
[27/Oct/2007:19:06:10] /opt/bin/rsync -a --delete --numeric-ids --relative --delete-excluded /usr /tmp/harddisk/backups/hourly.0/asus/
[27/Oct/2007:19:06:10] /opt/bin/rsync -a --delete --numeric-ids --relative --delete-excluded /tmp/harddisk/exchange /tmp/harddisk/backups/hourly.0/asus/
[27/Oct/2007:19:06:11] touch /tmp/harddisk/backups/hourly.0/
[27/Oct/2007:19:06:11] rm -f /var/run/rsnapshot.pid
[27/Oct/2007:19:06:11] /opt/bin/rsnapshot hourly: completed successfully
Now create cron rules to automate the process. Open /opt/etc/crontab and add lines
Code:
0 * * * * admin /opt/bin/rsnapshot hourly
30 23 * * * admin /opt/bin/rsnapshot daily
It is usually a good idea to schedule the larger intervals to run a bit before the lower ones. For example, in the crontab above, notice that daily runs 30 minutes before hourly. This helps prevent race conditions where the daily would try to run before the hourly job had finished. This same strategy should be extended so that a weekly entry would run before the daily and so on.
Read more at HOWTO rsnapshot (на английском))
If you configured cron as described in manual by macsat and you have folders cron.hourly, cron.daily etc just put scripts with appropriate commands to folders.
Example:
Code:
echo "#!/bin/sh" >> /opt/etc/cron.hourly/rsnapshot_hourly.sh
echo "rsnapshot hourly" >> /opt/etc/cron.hourly/rsnapshot_hourly.sh
chmod +x /opt/etc/cron.hourly/rsnapshot_hourly.sh
To find out how much space backups consume use built in command beacuse simple calculationg folders sizes gives wrong result because of symlinks.
Result will be like this
204652 /tmp/harddisk/backups/hourly.0
3040 /tmp/harddisk/backups/hourly.1
207692 total
Actual copy takes 204652 kb and previous versions take 3040 kb for deleted files.
Useful links