How to auto backup using rsync
September 1, 2009 @ 9:28 am Tags: auto, backup, crontab, rsync
This guide will auto backup folder within same machine using rsync and crontab. You must be login as sudo account or root.
Creating script
vi /root/rsync.sh
Copy paste this script. Remember to change the source folder or target folder
folder=`date +%Y_%m_%d`
rsync -avH /folder/to/backup /backup/$folder >> /var/log/rsync/acc
Make script executable.
chmod +x rsync.sh
or
chmod 755 rsync.sh
Create the folder rsync in /var/log
mkdir /var/log/rsync
Now add this script to your crontab. (Check this link for crontab reference)
crontab -e
# Run auto backup everynight
0 4 * * * /root/rsync.sh
Save the file… Hope this little guide helps!