LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 11-27-2008, 05:53 PM   #1
rust8y
Member
 
Registered: May 2006
Posts: 100

Rep: Reputation: 15
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.
 
Old 11-27-2008, 11:08 PM   #2
eggixyz
Member
 
Registered: Apr 2008
Posts: 310

Rep: Reputation: 30
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
 
Old 11-27-2008, 11:39 PM   #3
salter
Member
 
Registered: Oct 2008
Posts: 100

Rep: Reputation: 15
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

Last edited by salter; 12-20-2008 at 12:10 PM.
 
Old 11-27-2008, 11:44 PM   #4
jstephens84
Senior Member
 
Registered: Sep 2004
Distribution: (Home)Opensolaris, Ubuntu, CentOS, (Work - AIX, HP-UX, Red Hat)
Posts: 2,043

Rep: Reputation: 83
Quote:
Originally Posted by rust8y View Post
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]

Last edited by jstephens84; 11-27-2008 at 11:45 PM.
 
Old 11-28-2008, 03:36 AM   #5
ram_rajavarapu
Member
 
Registered: May 2008
Posts: 41

Rep: Reputation: 15
Try with scp command. The syntax is

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy recursively across directories stefaandk *BSD 1 11-09-2008 10:01 PM
How to copy directories sofasurfer Debian 10 01-01-2008 07:42 PM
SCP copying directories between servers astrollama Linux - Software 5 10-13-2006 03:10 AM
Copy files from different directories fiomba Linux - Software 3 02-11-2005 03:01 AM
copy directories and subdirectories Red Squirrel Linux - Newbie 2 03-06-2004 09:18 PM


All times are GMT -5. The time now is 08:11 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration