How to keep the full path with rsync?

Solution 1:

Use the -R or --relative option to preserve the full path.

Solution 2:

Another common related use case it to keep a selected part of the directory tree with /./, e.g. if you wanted:


you can write:

rsync --relative /home/udi/./files/pictures backup

The magic /./ tells rsync where to start creating directories from.

Solution 3:

With the Cygwin Windows rsync, and assuming the remote rsync is pointing to the root, I'd do:

rsync -vtrz --delete server::rsyncid/home/udi/files/pictures /cygdrive/d/backup/home/udi/files

That will put the contents of the remote pictures directory in /backup/home/udi/files/pictures. Presumably the syntax under unix would be similar.