When to end in slashes
General March 7th, 2008
In this week’s “how to be a sysadmin” installation, our hero learns the fine nuances of when to use and when *not* to use a trailing slash with directories with rsync.
One style is not better than another, but they are different, and today I’ve used both. From the man page:
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
Our hero is also learning that cygwin rsync to a samba share from Windows doesn’t work as well as he’d like.
About
Ah yes, the old rsync trailing slash epidemic. Been down that road before.