Copy Folders from one Unix server to another?

22

12

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?

user765851

Posted 2011-05-30T08:53:35.537

Reputation:

Answers

27

Yes, there is scp or the former rcp or rsync

scp -r source_folder user@host.com:destination_folder

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

Ozair Kafray

Posted 2011-05-30T08:53:35.537

Reputation: 1 030

if you want completeness, you should add the netcat method too. nc -l -p 9999 > file + cat file | nc ip port or nc -l -p 9999 | tar -x - + tar -c dir | nc ip port - has saved my skin a couple of times when i didn't have any fancy servers available, like linux installer systems – hanshenrik – 2018-11-03T09:14:10.860

1I haven't seen rcp for decades - does anyone still use that? – Piskvor left the building – 2011-05-30T09:01:20.077

@Piskvor: I have never used it either, but was just added there for completeness of the answer. – Ozair Kafray – 2011-05-30T09:03:55.740

12

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

Shirkrin

Posted 2011-05-30T08:53:35.537

Reputation: 231

4

You can use SCP:

scp -rp foldertocopy/ user@server:destination/

or

rsync

cularis

Posted 2011-05-30T08:53:35.537

Reputation: 1 169

-1

First login to the server to which you want to copy folder or file. Be in folder where u want to copy and execute command "wget http://sourceserverip/folderuwanttocopy.zip"

for this folderuwanttocpy.zip in source server should be in /var/www/html if it is linux server (or) xamp/httdocs if it is windows server

Soundarya

Posted 2011-05-30T08:53:35.537

Reputation: 1