rsync syntax quirk
2013-12-09
For me, rsync has replaced cp, sftp and other tools. Something that’s boggled me is simply the way it handles slashes ending a path:
rsync user@host:/etc /
is not the same as:
rsync user@host:/etc/ /
The former will copy everything from /etc/ on the remote machine to /, but it actually copies the directory, so it won’t only copy what cp -r /etc/* /backup/ would copy, but what cp -r /etc/ /backup/ would copy: it will create a directory /etc! The latter won’t create a directory and behave exactly like cp -r /etc/* /backup/ when it comes to handling the path.
Another thing, seemingly more innocent, is how it handles escaping characters on the remote end:
rsync user@host:/Annoying\ Directory ~
This wouldn’t work.
rsync user@host:/"Annoying\ Directory" ~
This would.