Solved

Rsync From VPS (CentOS) to Cygwin

Posted on 2013-12-03
4
648 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

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

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

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Learn how the use of a bunch of disparate tools requiring a lot of manual attention led to a series of unfortunate backup events for one company.
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
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.

828 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