Home of rsync is http://rsync.samba.org
Example script using rsync to sync some directories from given remote host to the local system:
#!/bin/bash # # 2008-02-10/TB # REMOTE=192.168.0.1 declare -a SOURCEDIR SOURCEDIR=" /etc/vsftpd.conf /var/www/ /root/scripts/ /home/admin/" LOG=/rs.log # to avoid a dry-run comment out the following line: DRY=--dry-run # reset or create the logfile (zero bytes): > $LOG for i in ${QUELLDIR[*]}; do echo -e "$i\n" >> $LOG rsync -av -e ssh --stats --delete $DRY $REMOTE:$i $i >> $LOG done
Some notes regarding slashes (taken from manpage):
A trailing slash on the source changes this behavior to avoid creating an additional directory level at the destination. You can think of a trailing / on a source as meaning “copy the contents of this directory” as opposed to “copy the directory by name”, but in both cases the attributes of the containing directory are transferred to the containing directory on the destination. In other words, each of the following commands copies the files in the same way, including their setting of the attributes of /dest/foo:
rsync -av /src/foo /dest
rsync -av /src/foo/ /dest/foo