Solved

Rsync From VPS (CentOS) to Cygwin

Posted on 2013-12-03
4
650 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
[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
  • 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Facing problems with you memory card? Cannot access your memory card? All stored data, images, videos are lost? If these are your questions...than this small article might help you out in retrieving your lost or inaccessible data.
Microsoft will be releasing the Windows 10 Creators Update in just a matter of weeks. Are you prepared? Follow these steps to ensure everything goes smoothly and you don't lose valuable data on your PC.
In this Micro Tutorial viewers will learn how to restore single file or folder from Bare Metal backup image of their system. Tutorial shows how to restore files and folders from system backup. Often it is not needed to restore entire system when onl…
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…

740 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