Beruflich Dokumente
Kultur Dokumente
Jason Clark
ver 07.04.10
Assumptions
● The RSync server (where you backup to) is a Linux box.
● The RSync client (what you want to backup) is a windows 2000 or newer machine.
● You can install software on the Windows machine and have Administrator access.
● You have port 22 (ssh) accessible on the Linux server
Software
● rsync installed on the Linux server. This is most likely already installed for you.
● cwRsync installed on the windows machines.
● openSSH installed and configured on the Linux server. It will be installed as part of the
cwRsync install on the Windows machine automatically.
Description
RSync is an extremely powerful and flexible opensource backup solution that is used in many products.
RSync is able to use encrypted connections or plain text for its transport, allows for incremental
backups and can transfer only the specific bits of a file that changed from the last backup.
RSync will run on all Unix Operating Systems, including Mac OSX, and most Windows Operating
Systems thanks to Cygwin. An RSync backup over ssh is depicted below.
Configuring ssh
Most likely this is already done for you, but verify that ssh will allow for key based authentication by
looking at /etc/ssh/sshd_config
If your results don't match the ones above, simply edit that file to match and restart openssh.
You do not need to define a password, but it may make things easier for you later on.
We now need to transport the id_rsa.pub key over to the Linux server. You can do this via a
thumbdrive, FTP via binary mode, or whatever method you have available. This file should be saved
into /home/backups/.ssh/authorized_keys.
At this point, you have setup public key authentication between the windows machine and the Linux
server. To test, run the following from the windows machine. You should be logged into the Linux box
over ssh without being prompted for a password. If you have to type in a password, go back through
this document again and see what step got missed.
At this point, RSync is backing up your windows machine to the Linux server! This first backup will
take a bit of time and you will get some errors about being unable to open certain log files because
windows likes to exclusive lock logs. Once the first run has completed, feel free to run this command
again and notice how much faster it runs! RSync is now only moving the bits that have changed across
the ssh connection. This command can now be stored in a batch file and run every day at a specific
time on the windows box.
NOTE that this does NOT take care of rotating backups. The /mnt/backups directory will always store
the most current backup., giving essentially one days worth of changes. The easiest way to do rotating
backups is to exploit the hardlink support of Rsync. The command only changes by one switch and a
directory, but it does require some additional work on the Linux server side.
#!/bin/bash
# Directory to backup to
DIR=/mnt/backups
YESTERDAY=`date +%A --date yesterday`
TODAY=`date +%A`
if [ ! -d $DIR/$TODAY/ ]; then
mkdir -p $DIR/$TODAY/
# Setup $DIR/current
ln -s $DIR/$TODAY $DIR/current
#setup $DIR/previous
ln -s $DIR/$YESTERDAY $DIR/previous
When run, this will create a symlink in /mnt/backups to current and previous. Now we just need to
tweak our backup command to look like this
C:\Program Files\cwRsync\rsync.exe -auv –delete –link-
dest=/mnt/backups/previous -e ssh /cygdrive/c/
backups@SERVER:/mnt/backups/current
And we now have 7 day rotating, incremental backups. You can verify that the symlink worked by
looking at the directory usage on the Linux servers backup directories
Restore is simply copying any file you want from the day of the week that you want back to your
windows machine via a thumbdrive, ftp, etc.