Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like to copy a folder from one Unix server to another Unix server. Can anyone tell me if there is a method or command to to achieve this?

share|improve this question
add comment

migrated from stackoverflow.com May 30 '11 at 17:01

This question came from our site for professional and enthusiast programmers.

3 Answers

Yes, there is scp or the former rcp or rsync

scp -r source_folder [email protected]:destination_folder

The command above will copy source_folder to destination_folder in the user's home directory on host.com

share|improve this answer
1  
I haven't seen rcp for decades - does anyone still use that? –  Piskvor May 30 '11 at 9:01
    
@Piskvor: I have never used it either, but was just added there for completeness of the answer. –  Ozair Kafray May 30 '11 at 9:03
add comment

If your folder contains subfolders and more importantly symlinks you want to use rsync:

rsync -aruv localfolder/ user@server:destination/

Or in reverse:

rsync -aruv user@server:destination/ localfolder/

This will do a recursive backup / copy from localfolder to your server while keeping ownership and permissions intact. The solutions suggested so far are valid however scp doesn't handle symlinks by default and will instead create a new copy of the linked file.

For detailed usage see man(1) rsync or here

share|improve this answer
    
Thnks guys, it worked, appreciate your help –  user765851 May 30 '11 at 9:27
add comment

You can use SCP:

scp -rp foldertocopy/ user@server:destination/

or

rsync

share|improve this answer
add comment

Your Answer

 
discard

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