Balack
asked on
How to use rsync to download files to another server?
There are 2 SUSE SLES11 servers in this setup. Both servers are located behinds firewall, and communicate through Internet. I intend to use rsync to frequently download the latest files from serverA to serverB. How should I setup the whole project? I heard that I can use SSH on top of rsync, is that right, and how it work?
ASKER
What ports have to be opened in sender's and recipeint's firewalls?
Allowing tcp port 22 from source to destination (from A to B in my example) will be enough.
By the way to download file from server B you have to use command as follows:
My first version was uploding to server B ....
rsync username@serverB:/directory/filename /directory/
My first version was uploding to server B ....
ASKER
I intends to schedule to run the rsync in cron job, and password prompt is not allowed. I heard that SSH is needed to setup with public and private keys. Is that true? If so, what are those steps?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
use options.. rsync -alvzn $localDir host:$remoteDir
z = compress (speeds transfer between hosts)
n = Dry run, it will test the command only. rerun the same command without -n to execute it.
l = follow symlinks
-a : Archive Mode
So you would use this command: rsync -alvzn rsync filename username@serverB:/destinat ion/direct ory
Then, if everything passes, run the same command without n:
rsync -alvz rsync filename username@serverB:/destinat ion/direct ory
z = compress (speeds transfer between hosts)
n = Dry run, it will test the command only. rerun the same command without -n to execute it.
l = follow symlinks
-a : Archive Mode
So you would use this command: rsync -alvzn rsync filename username@serverB:/destinat
Then, if everything passes, run the same command without n:
rsync -alvz rsync filename username@serverB:/destinat
Sorry about the double post.. you use only 1 rsync (copy paste ftl)
rsync -alvzn filename username@serverB:/destination/directory #Test
rsync -alvz filename username@serverB:/destination/directory #actual command
ASKER
I tested files/folders can be copied successfully. The main issue now is password prompting. How can I run without password prompting? As I intend to run it as a cron job.
Hi Ballack,
You can find detailed instructions on the link i provided...
--
You can find detailed instructions on the link i provided...
--
ASKER
It works like a charm
By default rsync will use ssh fot transport method. So if you have ssh connectivity between servers you can eaily acoomplish your transfer...
The syntax is straightforward:
to copy files from server a to b type
Open in new window
For detailed how-to try man rsync