Rsync : backup your data
Posted August 18, 2007on:
rsync use for synchronizing file trees. like in the man pages, rsync can be used :
- for copying local files. This is invoked when neither source nor destination path contains a : separator
- for copying from the local machine to a remote machine using a remote shell program as the transport (such as rsh or ssh). This is invoked when the destination path contains a single : separator.
- for copying from a remote machine to the local machine using a remote shell program. This is invoked when the source contains a : separator.
- for copying from a remote rsync server to the local machine. This is invoked when the source path contains a :: separator or a rsync:// URL.
- for copying from the local machine to a remote rsync server. This is invoked when the destination path contains a :: separator.
- for listing files on a remote machine. This is done the same way as rsync transfers except that you leave off the local destination.
By now, i want to back up my data to another server.
so i use it. first, i install rsync
make install clean
uid = userid gid = groupid use chroot = no max connections = 4 syslog facility = local5 pid file = /var/run/rsyncd.pid
[www] path = /usr/local/www/ comment = all of the websites
then edit permission rsyncd.conf to 640
after that start the daemon
that’s all for the server.
in the client install the rsync, but don’t start the daemon.
after that get the module www that refer to /usr/local/www of first server. the example command shell:
rsync -avz --delete xxx.xxx.xxx.xxx::www /backup/data1
that’s mean, i get data /usr/local/www from first server and transfer they to /backup/data1 to second server and delete files or folders that didn’t match again if we do the same command.
we use rsync to get the update data regularly. then we put the script into the /etc/crontab. for example :
7 * * * * root /root/script/rsync.sh 2>&1 | mail -s "rsync script" root
where the rsync.sh was :
/usr/local/bin/rsync -avz --delete xxx.xxx.xxx.xxx::www /backup/data1