
Using cwRsync on Windows and rsync on Linux you can seamlessly mirror directories on two or more computers. In my case, because of iTunes and an iPod, I’m forced to keep a copy of my library on a desktop computer and on my media server. Yes, I’m aware of mt-daapd and I already have it working; unfortunately that’s not a solution in this case.
What you’ll need:
- cwRsync, download and install on your Windows computer.
- rsync, install and make sure it’s running on your linux box
- Open a command prompt Start -> Run -> cmd
- Add cwRsync to your windows ‘path’ so that you can run it. Just type this at the command line:
path = %PATH%;c:\program files\cwRsync\bin - Create the Key
ssh-keygen -f /cygdrive/c/ssh_key -t rsa -N ''(please note; this creates your keys in the C: directory) - Copy your public key to the server:
rsync -e ssh /cygdrive/c/ssh_key.pub username@serverAddress:~/.ssh/authorized_keysYou’ll need to enter your username and password - Copy your public key into your ssh authorized_keys file:
ssh username@serverAddress cat ssh_key.pub >> .ssh/authorized_keys - Test your backup:
rsync -avz -e "ssh -i /cygdrive/c/ssh_key" "Desktop" username@serverAddress:folderNameThis should copy everything on your desktop to the directory named folderName on the server - Download and edit the sample batch file
- Once you’ve edited the sample batch file store it temporarily in the C: directory and run the batch file manually
c:\data-backup.bat - Set your batch file to run automatically: Go to Start -> Control Panel -> Scheduled Tasks and click ‘Add a Scheduled Task’. Next -> Browse. Set the schedule and enter your account password to allow the software to run.
I’m successfully using the sample batch file to mirror a music directory on my media server with a desktop computer.
While music is the subject of our conversation; give Chris And The Other Girls a listen. They’re less popular than they deserve to be. I particularly like track 01 Let Go, download it here.
Okay, looks like there’s a freely available open source, GUI wrapper for rsync. Give it a try and let me know what you think. Download and documentation can be found here
Update:
Awesome/Useful comments be sure to read them.
Sorry if you’re comments don’t show up for a while due to spam I have to curate.
If you’re having problems with Windows 7 being unable to create a .ssh directory (see Richard’s problem below). It looks like has a work around.
11 Comments
Hey, very nice article!
You skipped a VERY key step, makes the directions impossible to perform as is.
Windows does not have SCP and you don’t include any clue where this comes from.
Thanks Alvin, I didn’t want to write over any authorized key files one might already have in the .ssh directory on the server. I’ve updated this how-to. Now your “ssh_key.pub” should be copied over to the server as “authorized_keys” in the .ssh directory.
Please let me know if you have any other problems.
This is awesome. Thanks for sharing.
Step 5 is redundant though. You just need step 4.
Also if you are running Windows Server or something you have to be careful of the Program files directory in the batch file:
SET CWRSYNCHOME=C:\Program Files (x86)\cwRsync\
Nice tut, thanks!
IMPORTANT to know that in the Batch example file if you are running it from scheduled task you should change home directory from
SET HOME=%HOMEDRIVE%%HOMEPATH%
to
SET HOME TO %USERPROFILE%
in order to point to the correct path.
correction:
SET HOME=%USERPROFILE%
Great article – I am having one issue someone might know about here. When I run multiple rsync commands in the same batch file, I get a paasword prompt on the second rsync and onwards. Would the ssh session from the previous line be impacting the key call somehow??
DOH forget it – typo on the remote account O.o I should have waited before I commented lol.
THANKS!!!
This was very helpful, but running rsync under Windows7 I get something like this:
Could not create directory ‘/home/me/.ssh’.
The authenticity of host ‘myhost’ can’t be established.
RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/home/me/.ssh/known_hosts).
So Windows7 prevents the creation of any directory whose name starts with the period character. The rsync command itself works once I enter ‘yes’ at the prompts which are coming from ssh, but I cannot execute the command unattended.
The host is in fact a known host to my windows system, since I can connect with Putty and Filezilla, it’s just that command line ssh cannot create its directory named .ssh. Is there a syntax that will allow me to substtute PuTTY for ssh?
Got ssh to work: created the .ssh directory from the command line. No problem.
3 Trackbacks/Pingbacks
[...] In Tech explains how to do the same on Windows with cwRsync (a package of Rsync and [...]
[...] In Tech explains how to do the same on Windows with cwRsync (a package of Rsync and [...]
[...] E se alguén quere facer a proba desde o windows, que bote unha ollada acó. [...]
Post a Comment