Solved

Rsync From VPS (CentOS) to Cygwin

Posted on 2013-12-03
4
641 Views
Last Modified: 2013-12-03
{Disclaimer - I'm weak on Linux Don't assume I know something Basic!}

OK, I've been trying to get this sorted for a while, at the moment Ive got the whole thing running in ESX, until I work out how to do it, then I will replicate it on my live Web Server.

My Goal: To Be able to backup my complete VPS Linux Server running CentOS6, via Rsync to a Windows machine. So that it will connect (without prompting for a password) and backup the entire VPS.

How far I've got:

I've installed Cygwin (installed openssh, rsync, bash)
I've generated an ssh key - and I can scp the public key to the web server
I've create a user on the web server (default shell = bash)

I've spent a looong time reading articles on this, and I cant work out where the ssh key should be generated, where the public key needs to be copied to, how to get either machine to trust the other machines public key.

Can anyone help nudge me forward?

Thanks
0
Comment
Question by:Pete Long
  • 3
4 Comments
 
LVL 19

Expert Comment

by:xterm
ID: 39692966
All you need to do is copy the public key that you generated with ssh-keygen (id_dsa.pub or id_rsa.pub) to the .ssh directory of the user that you will be logging in as on the Cygwin/Windows server and name it authorized_keys.

The first time you ssh to the Windows server you will be prompted to accept and save the server's key.  It should then allow you in without a password, and all future logins should be promptless.

I'm thinking perhaps you did this in reverse - the public key needs to be generated on the server that will be doing the copying, so let's call it the client (aka, your Unix VPS)

Keep in mind that you need to run ssh-keygen as the user who will be doing the copy, which generates id_dsa.pub (if you used the "-t dsa" option) or id_rsa.pub (if you didn't specify.)  That will be the file that needs to be copied to the server side, and renamed to authorized_keys.

Please retry and let me know if/where you get stuck.
0
 
LVL 57

Author Comment

by:Pete Long
ID: 39693078
Ahh OK - I'm trying to do it the other way round, I want to instigate the copy from the Windows machine, via a simple script like this

So I've created, the id_rsa.pub  like so.....

key generated
Created a user on my Web server like so...

create backup user
Coped the over the file from the widows machine like so..

scp file
So using your example  - I would need to move that file (on the web server into the backupusers .ssh directory? (Im assuming this would be in that users home drive?) And finally rename id_dsa.pub to authorized_keys?

Then I can login from the windows box and instigate an rsync?

If I set the target to '/' will it replicate the ENTIRE Server?

Thanks for your help by the way :)

PL
0
 
LVL 19

Accepted Solution

by:
xterm earned 500 total points
ID: 39693135
You still have it backwards - rsync is run from the system that you want to back up which does a remote synchronization TO another server, hence it's name.

So you will need the openssh server running on the Windows side because it will receive the files FROM the Unix VPS.

Once you can ssh to the Windows machine successfully without being prompted for a password, then you can set up a cron with a script something like this:

#!/bin/sh

KEEPARGS="--delete"

BACKUPDIRS="/path1 /path2 /other/path"
for FOLDER in `echo $BACKUPDIRS`;
do
        rsync -az $KEEPARGS $FOLDER --exclude '/some/file/to/not/copy' -e 'ssh' cygwinbox:/path/to/backups
done

Open in new window

0
 
LVL 19

Expert Comment

by:xterm
ID: 39693177
FYI, I should mention that you CAN rsync in the direction you intended, but I think it's much cleaner to push the files from the source to the destination, especially since the source Unix machine has an easy scheduler already running - crond.

Good luck!
0

Featured Post

Google Storage: Standard vs. Nearline vs. Coldline

Google Cloud Storage has a number of classes to choose from. Although there are a lot in common, they vary in price and usage terms. This post explains Google Cloud Storage classes and helps to understand which  one to choose.

Join & Write a Comment

The article will include the best Data Recovery Tools along with their Features, Capabilities, and their Download Links. Hope you’ll enjoy it and will choose the one as required by you.
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…
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.

757 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

16 Experts available now in Live!

Get 1:1 Help Now