Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

When backing up with rsync, How do I keep the full directory structure?

For example, the remote server is saturn, and I want to backup saturn's /home/udi/files/pictures to a local directory named backup.

I want to have (locally) backup/home/udi/files/pictures rather than backup/pictures.

Any help?

Udi

share|improve this question

2 Answers 2

up vote 27 down vote accepted

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

share|improve this answer

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.

JR

share|improve this answer
    
It is not useful because we need to reproduce the whole directory hierarchy on the local side before executing the rsync command. –  Ludovic Kuty Apr 2 '12 at 11:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.