Rsync directory tree with symlinks

Step-by-Step descriptions of how to do things.
Post Reply
User avatar
^rooker
Site Admin
Posts: 1481
Joined: Fri Aug 29, 2003 8:39 pm

Rsync directory tree with symlinks

Post by ^rooker »

I wanted to backup an image of a directory structure on a server using rsync. I've found a handful of articles and knowledge base entries which said it can be done with this:

Code: Select all

$ rsync -a -f"+ */" -f"- *" source/ destination/
The command seemed alright, although I prefer the more readable form:

Code: Select all

$ rsync -a --include='*/' --exclude='*' source/ destination/
Looking good, but didn't move a finger in my setup. :?

I've used symlinks for gathering multiple partitions together in the source-dir I wanted to copy the directories from with rsync.

The solution is to add a "-k" to the rsync command:
-k, --copy-dirlinks transform symlink to dir into referent dir
So the correct command for this case looks like this:

Code: Select all

$ rsync -ak --include='*/' --exclude='*' source/ destination/
Links:
Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
Post Reply