Operating rsync

Size & timestamp (default)

Typical usage

rsync -avz --delete src dst

Beware of the trailing-slash on src/. If there is, its content will be replicated onto destination, not the folder.

Default behaviour

Size-only

This does not only ignore timestamps, but also filesize

-I, --ignore-times          don't skip files that match size and time

Therefore we need to ignore the timestamps only with

--size-only             skip files that match in size

Size-only & no perms

Instead of -a (which stands for -rlptgoD), you may also need to avoid p o g D in case you are re-generating some shit every time. Hence this is size-only.

rsync -rltvz --size-only --delete src dst

Checksum & no perms

in case you need to maintain different file permissions on source and destination

rsync -rltvz --checksum --delete src dst

Additional notes

Only use compression (-z) if that is over the network and not dealing with already compressed archives like music, films or anything not worth the cpu overhead.

dst/ doesn’t have to exist yet, rsync eventually creates it

Eventually switch to --rsh=rsh to speed up the process on a trusted network

Eventually add e.g. -e "ssh -palt_port" to tune SSH client options

Something usefull you might want to add to your scripts, not to cumulate rsync processes in parallel,

tmp=`ps aux | grep rsync | grep -v grep`
[[ -n `ps ax | grep rsync | grep -v grep` ]] && cat <<-EOF && exit 1
RSYNC IS ALREADY RUNNING, ABORDING
$̂tmp
EOF
unset tmp

One rsync job may have two child processes, in the end you have three

Resources

Parallelized rsync-like clone https://github.com/pscedu/psync

Why does rsync spawn multiple processes for me? http://serverfault.com/questions/547165/why-does-rsync-spawn-multiple-processes-for-me

Why does rsync forks itself? And why one such forked process is almost kinda idle (as seen in iotop)? http://serverfault.com/questions/460423/why-does-rsync-forks-itself-and-why-one-such-forked-process-is-almost-kinda-idl


HOME | GUIDES | BENCHMARKS | html