Solved

How to use rsync to download files to another server?

Posted on 2010-11-16
11
267 Views
Last Modified: 2012-05-10
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
Comment
Question by:Balack
  • 5
  • 4
  • 2
11 Comments
 
LVL 2

Expert Comment

by:ckiral
ID: 34146895
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
 

Author Comment

by:Balack
ID: 34147641
What ports have to be opened in sender's and recipeint's firewalls?
0
 
LVL 2

Expert Comment

by:ckiral
ID: 34147789
Allowing tcp port 22 from source to destination (from A to B in my example) will be enough.
0
 
LVL 2

Expert Comment

by:ckiral
ID: 34147927
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
 

Author Comment

by:Balack
ID: 34154561
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 2

Accepted Solution

by:
ckiral earned 500 total points
ID: 34154828
Hi Ballack,
I think following  tutorial will be usefull in that context:
http://troy.jdmz.net/rsync/index.html

0
 
LVL 2

Expert Comment

by:maxalarie
ID: 34159491
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
 
LVL 2

Expert Comment

by:maxalarie
ID: 34159504
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
 

Author Comment

by:Balack
ID: 34160759
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
 
LVL 2

Expert Comment

by:ckiral
ID: 34163521
Hi Ballack,
You can find detailed instructions on the link i provided...
--
0
 

Author Closing Comment

by:Balack
ID: 34179407
It works like a charm
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now