teirney.NET

Home

Tips and Tricks

This page contains a list of various tips and tricks that the average person on the internet may find useful. First up is how to use RSync to backup or archive files between two computers.

Using Rsync to Backup Files

Rsync is an open source utility that provides fast incremental file transfer. Rsync uses the Rsync algorithm which provides a very fast method for synchronizing remote files. It does this by sending just the differences in the files.

Rsync is developed by the same folk that constructed Samba, which provides file and print services to all manner of SMB/CIFS clients, including the numerous versions of Microsoft Windows operating systems (whilst quietly beating the pants off the native Windows implementation in terms of transfer rate).

I've been looking for a decent file backup mechanism for some time. The Windows Backup Utility is hopeless to use and is slow as pies. Rsync provides a relatively easy way to quickly backup and archive files. Below are the steps to follow to get yourself to the point where you can easily synchronize files.

  1. Download cwRsync from cwRsync - General
  2. Install cwRsync according to the instructions on the web page above.
  3. Append the bin directory of the installed location of cwRsync (something like C:\Program Files\cwRsyncServer\bin) to your PATH environment variable (so rsync is available on the command line)
  4. Create a mapped network drive to the machine containing the files that need to be backed up, or backed up to.
  5. Read the man pages for Rsync to understand what options are available when using rsync.

Next you need to test on something non-critical to make sure rsync is working.

  1. Create a folder on your C:\ drive called Test.
  2. Put some files into it.
  3. Create a folder on your C:\ drive called Backup.
  4. Open a DOS prompt
  5. Test a backup using the rsync command line tool.
    rsync /cygdrive/c/Test /cygdrive/c/Backup
    This will simply copy the contents of C:\Test to C:\Backup\Test.
Note the syntax that is used to map between the name of the drive as far as rsync is concerned and your actual file system according to Windows. /cygdrive/ is treated as being at the same level as My Computer.
C:\
/cygdrive/c
C:\Test
/cygdrive/c/Test
D:\
/cygdrive/d
D:\Multimedia Files
'/cygdrive/d/Multimedia Files' (note that quotes are needed if there is a space in the filename)

The only thing left to do is to determine what options to use. I am using the options -Cavz for all the file synchronization I am doing.

-C
auto-ignore files the same way that CVS does.
-a
archive mode - recurse into directories, copy symlinks as symlinks (not relevant on Windows), preserve permissions, preserve times, preserve group, preserve owner, preserve devices (not relevant on Windows).
-v
increase verbosity
-z
compress file data during transfer.
For example:
rsync -Cavz /cygdrive/y/Shelly /cygdrive/z
This copies all of the data from the Shelly share underneath my mapped network drive (Y:\) to my Z:\ (Backup) drive.

If necessary you could easily create a .bat file to do multiple drives and then schedule it using the Windows Scheduler. This is much easier than doing a Backup with Windows Backup and it's also much faster.

Depending on what software and hardware you have you can also use Rsync to work with a RW CD or DVD drive since it only updates files that have actually changed.