• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 529
  • Last Modified:

Remote RSYNC using SSH?

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
kandresen
Asked:
kandresen
1 Solution
 
grbladesCommented:
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
 
grbladesCommented:
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
 
kandresenAuthor Commented:
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
kandresenAuthor Commented:
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
 
jlevieCommented:
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
 
magicMushCommented:
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
 
kandresenAuthor Commented:
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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now