Home of rsync is

Example script using rsync to sync some directories from given remote host to the local system:

# 2008-02-10/TB
declare -a SOURCEDIR
# to avoid a dry-run comment out the following line:
# 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

Some tweaks I did to maximize throughput with a single destination disk

rsync -ahv --delete-before --numeric-ids \
--delete-excluded --stats \
--whole-file --inplace \
--exclude-from=excludes.txt \


-a #archive mode; equals -rlptgoD (no -H,-A,-X)
-H #preserve hard links
-h #human readable
--delete-before #receiver deletes before xfer, not during
--numeric-ids #don't map uid/gid values by user/group name
--delete-excluded #also delete excluded files from dest dirs
--whole-file #copy files whole (w/o delta-xfer algorithm)
--inplace #update destination files in-place

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
linux/rsync.txt · Last modified: 2013-12 by tb
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0 ipv6 ready