1752789 Members
5804 Online
108789 Solutions
New Discussion юеВ

Remote Copy help

 
SOLVED
Go to solution
Ian Derringer
Regular Advisor

Remote Copy help

Hi,
How do I do a remote copy from one Linux server to another Linux server? Let's say that I have options to log in to another server using ssh & telnet with "root" privs.

I need to copy entire folder from one linux server to another linux server. I am currently using Redhat 2.1 AS

Please help!!

Thank you in advance.
7 REPLIES 7
Ivan Ferreira
Honored Contributor
Solution

Re: Remote Copy help

You can use scp:

In the source host, run:

scp -rp localfolder username@remotehost:/path/to/destination_directory

Like this:

scp -rp mydir root@host.example.com:/home/

The use of root is not recommended for security reasons.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Ian Derringer
Regular Advisor

Re: Remote Copy help

Ok, let's see if I understand this correctly;
I should run this command from the server that I am trying to copy the data to, right?
Example: I have to server and they're x and y - and I am trying to copy data from y to x. The command are as follows:
scp -rp \temp root@y:/tmp/temp

This is correct? I hate to make a mistake by copying over the old stuff )-:

Thanks so much for your help!!

Ivan Ferreira
Honored Contributor

Re: Remote Copy help

I will give you examples:

Server 1 has the data to be copied. The mydata dir, located in /tmp (/tmp/mydatadir).

Server 2 is the destination. And should be placed in the /data directory.

You can do it from server 1 or server 2. Try to find out the differences in these examples:

From server1:

server1# scp -rp /tmp/mydatadir root@server2:/data

From server2:

server2# scp -rp server1:/tmp/mydatadir /data


Do you see the difference? The sintax is server:/location, and the order specifies if this is origin or destination.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Andrew Bruce
Valued Contributor

Re: Remote Copy help

Have you looked into using rsync?

man rsync should give you all you need (I'm assuming it is installed).

it is a file transfer utility that 'synchronises' files (or directories) from the source to the destination.

If you subsequently make a change to the files and re-run rsync, it will only transfer the differences, not the entire files all over again.

By default, rsync uses ssh for the comms, but you can also setup an rsync server that you can pull/push files from/to

An example of transferring an entire directory from server1 to server2 would be:

rsync -Cavz /opt/somedir server2:/opt/

The C option will back up any files that would be overwritten, 'a' is for archive mode (copy file properties as well as the file), 'v' verbose ;-) and 'z' to use compression (usefull on tight bandwidth).

You could even issue the command from a third server:

rsync -Cavz server1:/opt/somedir server2:/opt/

if ssh authorisation keys have not been exchanged, you'll be asked to enter passwords. If you have set up keys already, then things get even easier!

Good luck.

Regards,

Andy Bruce
I Love it when a plan comes together!
Ivajlo Yanakiev
Respected Contributor

Re: Remote Copy help

there are better way to do that


#tar -zcf - /yourdir | ssh dest_server tar -zxf - -C /dest_dir




Andrew Bruce
Valued Contributor

Re: Remote Copy help

?????

#tar -zcf - /yourdir | ssh dest_server tar -zxf - -C /dest_dir

is easier (better) than

# rsync -Cavz /opt/somedir server2:/opt/

???

You can't be a wizard!!! You must be impersonating Ivajlo Yanakiev, and I claim my 10 points! :-)

A.
I Love it when a plan comes together!
Muthukumar_5
Honored Contributor

Re: Remote Copy help

Several ways as,

a) You can use scp :/directory/* /

b) sftp

c) ftp -in < user
bin
cd /remote
lcd /local
mget *
bye
EOF

hth.
Easy to suggest when don't know about the problem!