LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Copy directories between two linux servers (https://www.linuxquestions.org/questions/linux-general-1/copy-directories-between-two-linux-servers-686725/)

rust8y 11-27-2008 05:53 PM

Copy directories between two linux servers
 
I am running Redhat Centos 5.2

ServerA (username: root, password: jam)

\Work
- file1
- file2
- file3

ServerB (username: root, password: butter)

What command do I use to copy everything including making a directory from ServerA \Work to ServerB?

Thanks.

eggixyz 11-27-2008 11:08 PM

Hey there,

check out the man pages for rsync; that command should do the trick for you. Otherwise you can use rsh or ssh (we'll assume that you've got .rhosts set up for rsh or key-based passwordless login setup for ssh) and do something like this from server A to server B

on A:

tar cpf - Work/file[123]|ssh B "cd /whatever/base/directory/you/want;tar xvpf -"

on B (getting from A) in the directory you want the Work directory to end up in:

ssh B "cd /whatever/base/directory/Work/is/in;tar cpf - Work/file[123]"|tar xvpf -

just substitute rsh for ssh if you want to use that instead. It's much less secure than ssh, but different people have different needs and, if that's not a concern, use whatever works best for you.

Best wishes,

Mike

salter 11-27-2008 11:39 PM

You can also use 'scp' directly to copy files between remote location. Have a look at 'man scp'. It's the copy tool of SSH, so it' quite secure.

Linux Archive

jstephens84 11-27-2008 11:44 PM

Quote:

Originally Posted by rust8y (Post 3357163)
I am running Redhat Centos 5.2

ServerA (username: root, password: jam)

\Work
- file1
- file2
- file3

ServerB (username: root, password: butter)

What command do I use to copy everything including making a directory from ServerA \Work to ServerB?

Thanks.

Also just to give you a little feedback, don't post passwords on a forum. While these may be test machines it is still bad practice and bad security.

yes rsync will work great for this.
Code:

rsync -r [directory] user@dest:[destination directory]

ram_rajavarapu 11-28-2008 03:36 AM

Try with scp command. The syntax is

# scp -r serverA IP:<obsolute path> <serverB local system path>


All times are GMT -5. The time now is 06:18 AM.