Tuesday, October 21, 2008

rsync: Be mindful of the trailing slash!

Pop Quiz: What's the difference between these two commands?

#1: rsync -a --delete /some/path/a/ /some/otherpath/
#2: rsync -a --delete /some/path/a /some/otherpath/


Answer: the first will make /some/otherpath mirror the contents of /some/path/a, while the latter will create a directory in /some/otherpath/a whose contents will mirror /some/path/a.

Be warned! If you're not careful and you use #1 when you intend to use #2, you can lose files in /some/otherpath.

Edit: Found this resource online: Rsync explanations and recommendations