Cwrsync – File transfer made Easy!

When you think of a backup tool, what comes to your mind?

At our  own Bat Cave,  Rsync[1] is atop when we talk about file transferring espcially if you wish to keep remote files in sync with your local files.  Why do we back up files? For obvious reasons, when one fails, you need a backup.
We do have a number of implementation using Rsync tool for file backup in lieu of more expensive brands and implementations in the market.

Just recently, one of our friends sought our help to remotely sync their files from an existing Windows machine into a Linux machine running samba. Simply, they needed to have their files /folders mirrorred on a machine on which a timestamp will be appended on each file/folder sync.

For example:
There exist a “Myfiles” Folder from a Windows machine which will be copied or mirrored to a Linux machine with a foldername “MyFiles-04302011” and if the user wishes to back this up daily, this same step will recur on the same time tomorrow and so forth with the respective date.
The implementation was executed and accomplished simply and easy with the use of  [2a]cwrsync – Rsync for Windows. Lucky for those who are looking for ways to back up files, because this is your day, let me share with you how we did it.

Here are the simple steps:
1.First, you need to install samba on a Linux Machine. Do create a share folder and set permisison depending on the policy that you or your company require.
2. Then install cwrsync client on the existing Windows machine
3.Create a batch script that will utilize rsync command
4.Map the created Linux share folder and treat it as a “network drive” on your Windows machine
5.Configure Windows Scheduler that will execute your batch file on the preferred time/day you wish to run the backup procedure.

Note though that the steps above assumes that your Linux and your Windows  XP  is connected to each other via network.

Step 1.Install Samba[1a] on the Linux Machine and adding user, using smbpasswd
Installing Samba on KahelOS machine is very straight forward, you can just execute a pacman command to do this.
$sudo pacman -S samba
$sudo vim /etc/samba/smb.conf <-this is where you configure your shared folder

ie. If I want to share a “public” folder,  just add at the end of my config file these lines

[public]
path = /home/public
public = yes
only guest = yes
writable = yes
printable = no
$sudo smbpasswd -a public

note: for advance config and more information about samba config, you can always check  smb.conf file and its manual [2]

Stoppping and Starting Samba Server:
To start your samba service, simply invoke this command
$sudo /etc/rc.d/samba start

And to stop your samba service, type this on your console
$sudo /etc/rc.d/samba stop

STEP 2: Install cwrsync client on the windows machine

Download cwrsync client [3] and install it on your windows machine

<SCREENSHOTS>

STEP 3:Create a batch script that will utilize rsync command.
After installing the cwrsync, create a batch file at your windows machine.

This batch file script assumes that:
-MyFiles Folder is located on Drive C:
-That Drive “O” is the mapped drive for Linux samba machine
Here the batch file which we named sync.file.cmd and inside this file we created this sample rsync script. (You may cut and paste this if you want)

@ECHO OFF
SETLOCAL
SET CWRSYNCHOME=%PROGRAMFILES%\CWRSYNC
SET HOME=%HOMEDRIVE%%HOMEPATH%
SET CWOLDPATH=%PATH%
SET PATH=%CWRSYNCHOME%\BIN;%PATH%
SET dt=%date:~10,4%%date:~4,2%%date:~7,2%

rsync -r –progress /cygdrive/c/MyFiles/ /cygdrive/o/MyFiles-%dt%

STEP 4: Map Linux shared folder and treat it as “network drive” on your windows machine .Also check How to connect and disconnect a network drive in Windows XP [4]

STEP 5:.Configure Windows Scheduler [5] to execute your batch file script on the preferred time/day to run the backup.

<SCREENSHOTS>

When you have your Windows and Linux machines and have followed each step, you can now start testing the samba share, batch file script and windows scheduler.

Enjoy!

References:
[1]rsync utility-http://rsync.samba.org/
[1a] Samba- http://www.samba.org/
[2] smb.conf — The configuration file for the Samba suite http://samba.org/samba/docs/man/manpages-3/smb.conf.5.html
[3] cwrsync client: http://prdownloads.sourceforge.net/sereds/cwRsync_1.2.5_Installer.zip?download
[3a] Rsync for Windows.-http://www.itefix.no/i2/node/10650
[4]How to connect and disconnect a network drive in Windows XP- http://support.microsoft.com/kb/308582
[5] How To Schedule Tasks in Windows XP -http://support.microsoft.com/kb/308569

This entry was posted in Administration, Utilities and Tools and tagged , , , , , , , , . Bookmark the permalink.

Leave a Reply