This is a card in Dave's Virtual Box of Cards.

rsync notes

Page created: 2024-06-07
Updated: 2026-01-06

My rsync (the very useful file copy utility) notes:

rsync Source directory trailing slash

For me, one of the hardest things to remember is when to use a trailing slash when syncing a directory:

$ rsync -r foo     <--- copy the directory itself

versus

$ rsync -r foo/    <--- copy the *contents* of the directory

In other words, these two commands are equivalent:

rsync -av /src/foo /dest
rsync -av /src/foo/ /dest/foo

To quote the man page:

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.