Using rsync to backup windows files to linux server

I set up my fathers windows PC to backup his pictures to my linux server using the following steps:

Download grsync for windows from here: http://sourceforge.net/projects/grsync-win/

From Command Prompt set up “public/private key pair”

cd C:\Program Files\Grsync\bin

ssh-keygen

Just take defaults and it saves the id_rsa.pub and id_rsa.key to a .ssh directory under you windows User directory.

Next Copy this file up to the server using the scp command (comes with grsync)

scp -p22 c:\Users\USERNAME\.ssh\id_rsa.pub username@linux_hostname_or_ip:/tmp

Then from the linux server put the id_rsa.pub file contents in /home/username/.ssh/authorized_keys file

mkdir /home/username/.ssh
cat /tmp/id_rsa.pub > /home/username/.ssh/authorized_keys
chmod 600 /home/username/.ssh/authorized_keys file

Then test to see if you can get in without password prompt using ssh command

ssh.exe -p22 username@linux_hostname_or_ip

If it lets you in without a password you’ve got it configured properly and are ready to use rsync to back it up

Now make a batch file called mybackup.bat file with this command (ALL ON ONE LINE)

C:\Program Files\Grsync\bin\rsync -az –progress –rsh=”./ssh.exe -p22″ /cygdrive/c/PATH_ON_C_TO_SYNC username@linux_hostname_or_ip:/PATH_TO_SERVER_LOCATION

When you run the bat file the first time it will copy everything.

If you run later it will copy only the changed files.

You can add this bat file to a scheduled job to have an automated backup process.

NOTE: The -p22 reference is specifying the default port 22 for ssh — change it if you have configured SSH to listen on a different port.

Also — Make sure your firewalls are open to allow incoming SSH traffic on the specified port on the server location.

 

This entry was posted in Uncategorized and tagged . Bookmark the permalink.