Sonora Communications, Inc.

  • Increase font size
  • Default font size
  • Decrease font size

Back up a Windows Host or VM to a Linux Host

E-mail Print PDF

Scenario

The goal of this howto is to back up some important files from a Windows machine (or VM) to a Linux host (or any rsync-capable host).

We will assume the Linux host is configured for tape or on-line backup.

I wrote a simple script called rsync_bu.sh that can be run from the command line or it could be run from cron for regular, scheduled backups. You may want to modify it to meet your needs.

I decided to pull the data from the Windows host (rather than push it from) because scheduling processes in Windows sucks and cron is easy and reliable. This method is also quite bandwidth-efficient.

I installed a very simple rsync server daemon on the Windows host and I opened the Windows firewall only for the backup server to minimize risks. If you are on a LAN and your Windows host is not exposed to the internet (port 873), you can take more or less security precautions as you see fit.

On the Windows Host (VM) to Be Backed Up

Download and install DeltaCopy. We will only use the server portion and we'll run it as a service.

You could probably use cwRsync, as well. I have used it before, but I think DeltaCopy is simpler.

When configuring the service, you will need to run it as a user with administrative privileges that has access to all the files on the hard drive...or at least to the files you want to back up. The quickie choice is 'administrator', but you may have a better plan.

You need to configure the rsync 'share'. In DeltaCopy, they use the term Virtual Directory. You can just rename and modify the default Backup share it creates for you. Make sure your share will give access to the files you want to back up. Create multiple shares if you want. I just shared the whole C: drive and called it "CDrive" and I made it read-only. I didn't check the "Use Authentication" checkbox, it complicates things a little.

If the Windows firewall is turned on, you need to create an exception. You can use rsync.exe or just open port 873. I changed the scope of the exception to be just the IP address of the backup server to limit the security risks.

On the Linux Host (Backup Server)

Download this Simple RSYNC Backup Script and modify it to your needs. You will probably only need to set a couple of variables at the top if you only have one share.

wget -O rsync_bu.sh "http://www.sonoracomm.com/index.php?option=com_rubberdoc&view=doc&id=10&format=raw"

After modifying the script to suit, you can then run the command from the command line or from cron.

./rsync_bu.sh 2>&1 | tee /root/rsync_bu.log

Configure Cron

This assumes the script is in root's home directory - /root. Adjust to your preferences.

Modify the system crontab something like this:

cat >> /etc/crontab << EOF
# Back up the accounting system at 10PM on weekdays
#+-----------------------Minute (0-59)
#|  +-------------------Hour of Day (0-23)
#|  | +---------------Day of Month (1-31)
#|  | | +-----------Month of Year (1-12)
#|  | | | +-------Day of Week (0=Sun,6=Sat)
#v  v v v v
00 22 * * 1-5 root /root/rsync_bu.sh >/root/rsync_bu.log 2>&1

EOF
SME Server

If you are using SME Server, you have to use the templating system to modify the crontab file:

Create a custom template fragment:

mkdir -p /etc/e-smith/templates-custom/etc/crontab
vi /etc/e-smith/templates-custom/etc/crontab/40rsync_bu

Add the following lines (plus a blank line at the end) to the new file and save:

# Back up the accounting system at 10PM on weekdays
#+-----------------------Minute (0-59)
#|  +-------------------Hour of Day (0-23)
#|  | +---------------Day of Month (1-31)
#|  | | +-----------Month of Year (1-12)
#|  | | | +-------Day of Week (0=Sun,6=Sat)
#v  v v v v
00 22 * * 1-5 root /root/rsync_bu.sh >/root/rsync_bu.log 2>&1 

Recreate the /etc/crontab file:

/sbin/e-smith/expand-template /etc/crontab
Verify your modifications:
cat /etc/crontab
Last Updated on Sunday, 12 April 2009 11:05  

Your external IP

You are connecting to this site from: 38.107.179.231

Secure Client Login

Email Address:

Password: