Now for the latest article of this first rsync saga I'd like to share with you my current Windows clients configuration, as I've already explained, rsync is quite easy to understand and configure; in your windows client you only need these files:
Copying.txt is the GPL public license, it's needed only for license purpouses, the other files: 2 DLLs (cygpopt-0.dll, cygwin1.dll) and 1 EXE file (rsync.exe) are part of your solution. As you imagine these files are taken from a working cygwin installation: you can download them from the net, from a working cygwin environment or directly from [this link where I've provided them for you]. These files allows rsync to work properly and syncing your local disk with a remote RSync server.
Rsync has an excellent manual and configuration page, a ton of options ready for you, here's just what I'm using for my backups:
rsync --verbose --recursive --compress --delete --perms --owner --group --specials --stats --devices
--links --times --exclude=”system*” “/cygdrive/c/backuphomedir/”
“array1_backup@myfavoritenas::array1_backup/ComputerID/” 1> “errorlog.txt” 2>&1
This is the raw command used for tests, of course you need to script it in a batch file or wherever you want. I don't want to enter into rsync syntax flags deeply when you've an excellent man page (like this one [http://www.samba.org/ftp/rsync/rsync.html]), but briefly:
--verbose be verbose on operations, useful for generated log file
--recursive copy directory specified and go recursively into subdirs
--compress compress file data during transfer
--delete delete file from remote host if local files doesn't exists anymore
--group --specials preserve group and special files
--stats give some transfer statistics (again, useful for logging)
--devices preserve device files
--links preserve links
--times preserve modification times
This command works with previous samples from past episodes, now pay attention to parameters related to your own machine settings like:
/cygdrive/c/backuphomedir/ it's the home dir where you want to start from copying your data, for Windows users the translated path is “C:ackuphomedir“, I've reported “/cygdrive/c/backuphomedir/” because cygwin environment starts with “/” (as UNIX), then it appends “cygdrive” (all local drives) then the name of the Windows drive “c”, then your backup sourcedir; (backuphomedir).
--exclude flag: directories to exclude from your backup path (inside c:ackuphomedir), so directories starting with “system” (like: c:ackuphomedirsystem, c:backuphomedirsystem32, …) will be excluded from your copy. Why ? Because I store rsync, DLLs and my batch file inside this dir
array1_backup@myfavoritenas::array1_backup/ComputerID is the rsync path where you want to sync your data, “myfavoritenas” is the machine name, “array1_backup” are username and “rsync share point”. ComputerID is just a directory inside your rsync share point, use different directories for different PCs so you've a dir for each pc of your net (use MachineID, username or whatever you want).
errorlog.txt is my log file where rsync operations are stored, very useful for further readings
If your rsync share point has a password as mine you need to type it on command line if you're executing this command as it is; if you're scripting it into your own program you need to export a Windows variable called RSYNC_PASSWORD (set RSYNC_PASSWORD=”your pass”) to have it running, read rsync manual page for details.
Be careful about locked files, rsync and every windows program will fail the backup if the file you want to copy is locked by someone else, an example ? Take a look at Outlook .PST files, you cannot copy them when Outlook is opened
Here are few considerations for applying this solution in a real environment, here's my experience:
I've set a “resume time” in BIOS for every PC I've in my net (example: wakeup at 00:01 am)
- I've inserted a scheduled job (windows scheduler is fine for me even if it's nothing fancy) which runs a C++ application created by me (example: start app at 00:30 am)
- My applications acts as a wrapper to rsync, makes its own copies and so on
- When copy is finished to powers off the PC again, if the PC was already on (user leaved the computer on from yesterday) I leave it on by checking computer uptime
That's it !
Why using this kind of solution against others ?
GPL, no license fees, easy configuration, easy customization
- Easy server installation, no custom packages or services, rsync is well known for its simplicity and configuration
- RSync support and documentation is HUGE across internet, there're a lot of things done with it
- Multiplatform: linux/OS-X/Windows/... you don't care about the operating system, you just need to have rsync compiled (cygwin for windows is ok) but you can also have your XYZ operating system or whatever you want. Not so many backup solutions have a port for nearly every existing platform like rsync has
No installation on Windows platform, I know, this is a rude solution but it works fine and flawlessly; I've just paired windows scheduler with rsync. No setup, no install, no virtual machines/.NET/... just copy the files
This episode concludes my first RSync saga, nothing strange or complex, just a common use of rsync in a real environment for handling daily operations in a network.
Hope it helps you to save time
Glad to read your comments here if you find it useful
Andrea (Ben) Benini