Now it's finally time to do the backup. Bring up a command prompt on the client machine. The command I run to back up all my music (which should be all on one line) is:
rsync -avzr -e "ssh -i /cygdrive/c/Documents and Settings/Kevin/.ssh/open_ssh_key -p 1433"
kevin@localhost:"/cygdrive/c/My Music/" "/cygdrive/c/My Music/"
So what do all the options mean?
- avrz means: Archive, Verbose, (Z)compressed, and Recursive.
- The -e flag specifies the shell to use, in this case we are telling SSH to use the OpenSSH private key (not the PuTTY .ppk one) we exported from PuTTYgen earlier.
- kevin@localhost:"/cygdrive/c/My Music/" is the source. Since I am tunneling, I use localhost as discussed earlier. If you don't have restrictions on your outgoing firewall, you can just put the hostname here.
- "/cygdrive/c/My Music/" is the destination. Because the Windows implementation of rsync is derived from Cygwin, you need to add /cygdrive/ to your path.
rsync should then start listing all your music as it synchronizes it to your client machine. The first time will obviously be quite slow, but after that it will only sync the files (and parts of them) that have changed.
I run the above script every time I aquire a new album or a similar script after I have taken some new photos. But you might well want to schedule it to run daily. It does no harm, as it will download virtually nothing if nothing has changed.
If you aren't using tunneling, then really all you need to do is create a batch file and paste your version of the rsync command above, and then schedule it using Windows Scheduled Tasks which can be found in the Control Panel.
If you are using a tunnel, then things get much more complicated. You will need to load up PuTTY, wait for it to connect, run your rsync command(s), and then close PuTTY. I have created the following VBScript file to help you do this:
Option Explicit Const PUTTY = "C:\Progra~1\PuTTY\putty.exe -load saved_session" Const RSYNC = "rsync -avzr -e ""ssh -i """"/cygdrive/c/Documents And Settings/kevin/openSSH"""" -p443"" " Const RSYNC2 = "--chmod=a+rwx kevin@localhost:""/cygdrive/c/My\ Music/"" ""/cygdrive/c/My Music/"" " Const PAUSE = "ping 127.0.0.1 -n 5 -w 1000" Dim objWMIService, objWMIProcess, WshShell Dim intPID ' Start PuTTY Set objWMIService = GetObject("winmgmts://./root/cimv2:Win32_Process") objWMIService.Create PUTTY, null, null, intPID ' Wait for PuTTY to load Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run PAUSE, 1, true ' Start Rsync Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run RSYNC & RSYNC2, 1, true 'Stop PuTTY Set objWMIProcess = GetObject("winmgmts://./root/cimv2:Win32_Process.Handle='" & intPID & "'") objWMIProcess.Terminate()
Save this to a file called rsync.vbs, or anything ending in .vbs, and then schedule it to run as before.
The script isn't great, so if you really want to automate the rsync using tunneling, I suggest you do a full Cygwin install, and use the Connect program I mentioned above.
If you are using the script, then there are three constant (Const) strings at the top of the script that you will need to edit. The first one is the location of PuTTY and the name of the session to load. The second is your rsync command. Note how the quotes in the original command have now become double quotes. The third statement is the pause to wait for PuTTY to connect. This uses ping, which in this case, will ping the localhost 5 times, waiting no more than a second for each one. You probably won't need to change this.
So there we have it, free offsite backup, what more could you ask for?
Using this method and the uplink rate of 45KB/sec from my home ADSL line, I can back up just over a gigabyte each day, should I need it. This should be enough to keep most people up-to-date.
So the next time someone asks you how much data you would lose if your house burned down, you can say "Nothing!".