« Return to FAQ Database

Backup with rsync on Windows

Source http://www.howtogeek.com/175008/the-non-beginners-guide-to-syncing-data-with-rsync/ but edited at the end:

rsync is built to run on Unix-like systems, there’s no reason that you shouldn’t be able to use it just as easily on Windows.  Cygwin produces a wonderful Linux API that we can use to run rsync, so head over to their website and download the 32-bit or 64-bit version, depending on your computer.

Installation is straightforward; you can keep all options at their default values until you get to the “Select Packages” screen.

 

 

Now you need to do the same steps for Vim and SSH, but the packages are going to look a bit different when you go to select them, so here are some screenshots:

Installing Vim:

 

Installing SSH:

 

Once installed you need to create no password login into remote Linux server. To accomplish that we need to generate and add pub key into remote Linux server. On Debian it is located in /home/user/<name of user how we will login>/.ssh/authorized_keys. We need to paste generated key as one line into that file.

To generate key on windows machine we open up cygwin terminal. Issue command there: ssh-keygen -t rsa

 

On Linux remote machine we need to restart SSH /etc/init.d/ssh restart

 

Create a sh file in cygwin install directory (c:\cygwin64\). backup.sh

rsync.exe -avzhPR --chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r --delete --stats --log-file=/home/Administrator/rsynclogs/backup.log -e 'ssh -p 2221' /cygdrive/c/Shared/ user@ip of server:/backup/TeoSrv/

ssh -p 2221 is the port where remote Linux server ssh daemon is running. Usually it is port 22 but in my case it was behind the firewall on port forwarding.

Then in task scheduler create new task with:

Program: C:\cygwin64\bin\bash.exe

Add Arguments: --login -i '/backup.sh'

Start in: c:\cygwin64\bin

 

Good website to look at http://docs.oracle.com/cd/E18930_01/html/821-2426/gksiy.html