?
Solved

Remote RSYNC using SSH?

Posted on 2004-08-23
7
Medium Priority
?
488 Views
Last Modified: 2013-12-15
Hello All,

I am currently working with one server with a fixed ip address, and a backup server with a dynamic ip address.

The objective is to automize the backup process by running a cron job from the backup server.

I am using rsync for syncronizing the servers, however and since the ip is changing, the command need to be issued from the backup server so I may pass the new ip with it.

This is the script I first tried:

#!/bin/bash
ipaddr=`ifconfig ppp0 | grep "inet addr:" | cut -d ":" -f 2 | cut -d " " -f 1`;

ssh -l webserver "rsync -e ssh -aRvvz / backup@$ipaddr:/srv/backup --exclude=maillog --exclude=ftp.log --exclude=access.log --exclude=core --exclude=/var/lib/mysql --exclude=/dev --exclude=/proc --exclude=/mnt --exclude=/tmp --exclude=/var/spool/mail --exclude=/var/log --exclude=/var/www --exclude=/var/spool/MailScanner;";




I
0
Comment
Question by:kandresen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 36

Expert Comment

by:grblades
ID: 11873409
I normally just use rsync as in the following example to do it over ssh

rsync -a --delete -e ssh / backup@$ipaddr:/srv/backup --exclude=maillog --exclude=ftp.log --exclude=access.log --exclude=core --exclude=/var/lib/mysql --exclude=/dev --exclude=/proc --exclude=/mnt --exclude=/tmp --exclude=/var/spool/mail --exclude=/var/log --exclude=/var/www --exclude=/var/spool/MailScanner
0
 
LVL 36

Expert Comment

by:grblades
ID: 11873428
Sorry I have just realised what you are doing.

Cant you run a ddns client on the backup server and then just refer to it by its name?
http://www.dyndns.org/services/dyndns/
0
 

Author Comment

by:kandresen
ID: 11875198
Thanks for your comments, unfortunately I am not allowed to add such a service on the backupserver...

I will thus still be looking for a solution for passing the information through ssh, then have the server rsync'ing back again.

Kenneth
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 

Author Comment

by:kandresen
ID: 11875445
I am realizing that my command was mostly correct all the time - the problem was that when the ip changes, the ssh connection asks me if I am sure I want to add the new ip to the list... It seems to be failing as the script I initialized cannot confirm the question...  I believe it will get fixed as I add the -f parameter to tell ssh to run in background.

Anyway thanks for all comments!
0
 
LVL 40

Accepted Solution

by:
jlevie earned 200 total points
ID: 11875769
Why not run the rsync on the backup server? That way you don't need to deal with a changing IP. Something along the lines of:

rsync -e ssh -Cav --delete backup@fixed-ip.dom.tld:/ /srv/backup ...
0
 
LVL 1

Expert Comment

by:magicMush
ID: 11888335
to automatically add the fingerprint to the known hosts
if you have an access to ssh configuation on backup machine

edit your ssh configuration file

usually located at

/etc/ssh/ssh_config

uncomment the line
#      StrictHostKeyChecking ask

and change it to
   StrictHostKeyChecking no

this might solve your problem.
0
 

Author Comment

by:kandresen
ID: 11893729
Hello all,

I got it to work already using ssh and rsyncing back again, however I an noticing that the rsync method jlevie is mentioning removes a lot of the security risks I am seeing with my current approach - I had to put a certificate on the backupserver for making it work thus letting anyone with access to the mainserver also easy get access to the backup server. By making jlevie's approach I can remove the certificate again.

Best regards,
Kenneth
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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.
Suggested Courses
Course of the Month8 days, 16 hours left to enroll

764 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