Backup with rsync

rsync can be used to copy files from one machine to other over network.I use rsync over ssh to take backup of my server files.ssh is configured with public key authentication so it does not ask for password everytime when rsync starts.I scheduled it as cron job so it runs every night.rsync does incremental copy so it saves time and network bandwidth.

Following are the files and entries added to start and stop the copy operation in backup server.

create file backup_start in /etc/cron.d.Paste the below line in it.

59 21 * * * root /usr/bin/rsync -avz --log-file=/var/backup/rsync.log -e "/usr/bin/ssh -C -oCompressionLevel=9" 172.16.0.10:/all_back_dir /var/backup/dir

Above command will start copy thru rsync every night at 9:59 pm.

If your data is huge and takes more time, you can schedule command in cron to stop rsync in the morning.

create file backup_stop in /etc/cron.d.Paste the below line in it.

59 08 * * 1-5 root /bin/pidof rsync | xargs kill -15 >> /var/backup/rsync.log 2>&1

Above command will stop the rsync operation every weekday at 08:59 am.

This is very crud way of taking backup over network, but it seem to do the job.