Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 717
  • Last Modified:

Rsync From VPS (CentOS) to Cygwin

{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
Pete Long
Asked:
Pete Long
  • 3
1 Solution
 
xtermCommented:
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
 
Pete LongTechnical ConsultantAuthor Commented:
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
 
xtermCommented:
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
 
xtermCommented:
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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

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