Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 305
  • Last Modified:

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?
0
Balack
Asked:
Balack
  • 5
  • 4
  • 2
1 Solution
 
ckiralCommented:
Hi,

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
rsync filename username@serverB:/destination/directory

Open in new window

For detailed how-to try man rsync
0
 
BalackAuthor Commented:
What ports have to be opened in sender's and recipeint's firewalls?
0
 
ckiralCommented:
Allowing tcp port 22 from source to destination (from A to B in my example) will be enough.
0
Build your data science skills into a career

Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.

 
ckiralCommented:
By the way to download file from server B you have to use command as follows:


rsync username@serverB:/directory/filename  /directory/

Open in new window



My first version was uploding to server B ....
0
 
BalackAuthor Commented:
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?
0
 
ckiralCommented:
Hi Ballack,
I think following  tutorial will be usefull in that context:
http://troy.jdmz.net/rsync/index.html

0
 
maxalarieCommented:
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:/destination/directory
Then, if everything passes,  run the same command without n:
rsync -alvz rsync filename username@serverB:/destination/directory
0
 
maxalarieCommented:
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

Open in new window

0
 
BalackAuthor Commented:
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.
0
 
ckiralCommented:
Hi Ballack,
You can find detailed instructions on the link i provided...
--
0
 
BalackAuthor Commented:
It works like a charm
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 5
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now