Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a /home/jbruni folder in a VPS running Ubuntu Server 10.04 LTS (Lucid Lynx).

I am about to turn this VPS off and move some things from it to a new VPS, also running the same Ubuntu version.

At the moment, I want to move all contents at /home/jbruni from the "old" VPS to the new one.

1) I want to preserve all file permission and ownership settings (I don't want to use any chown or chmod after the transfer). [Note: the new VPS already have the same users/groups with same UIDs/GIDs.]

2) I want to preserve all symlinks and hardlinks, although I believe there is not a single hardlink in this case. I have lots of symlinks, both for files and for folders, all pointing to locations inside the own /home/jbruni folder.

3) I'd really like to preserve date and times (mtime, atime, ctime). [If not possible, ok... it is not that bad.]

4) I don't have enough disk space to create a big file containing everything in the "old" VPS prior to transfering it (like a big tarball). Anyway, I may acquire this temporary extra space if really really needed.

So, what I want is like a "mirror" of the source folder. Is there a way to accomplish this easily? (Or even not so easily?)

Thank you!

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

rsync!

rsync -azv -e ssh ./localdirectory/ user@otherserver:/remote/dir

-a is the bad-boy here. It's actually a metaargument that calls -rlptgoD which means, amongst other things:

  • Recursive
  • Preserve symlinks
  • Preserve permissions
  • Preserve modification times
  • Preserve group
  • Preserve owner
  • And preserves special stuff

It won't preserve hardlinks because hardlinks are files (well it's actually a pointer to an inode that stores a filename - but that's what a regular file is too - when you make a hardlink you're just giving an inode an extra filename). This shouldn't be an issue for you because they're quite rare IMO.

-z will attempt to compress the data in the stream (speed things up a bit).

-v will make sure it's giving you plenty of output.

share|improve this answer
    
Perfect! I am pleased to see it in action right now. Thanks a lot. –  J. Bruni Oct 17 '11 at 1:04
    
I just had to figure out from which server should I run the command. :-) It worths mentioning that it is from the source server, not the destination. –  J. Bruni Oct 17 '11 at 1:11
1  
You can actually run it from either server. The command is <source> <target> so you could run user@otherserver:/remote/dir ./localdir/ –  Oli Oct 17 '11 at 1:22
    
Thanks for the improved answer containing the parameter details and for the extra tip in the previous comment. Very nice! –  J. Bruni Oct 17 '11 at 1:41
add comment

I would use rsync for that. I believe it's installed by default in Ubuntu, but if it's not, then you can install it from the archives.

share|improve this answer
add comment

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.