Backing Up Your Data With cwRsync and sync2nas

One of the most crucial tasks facing an admin is backing up your data. Many admins work very hard at keeping the servers running at peak performance and keeping the software up to date. However, many forget the most important task. Backing up the data. Yes we all sometimes forget to do a daily data backup. I used to forget about backing up the data daily until one of the databases became corrupt and unusable. I had to roll back to data that was over a month old losing hundreds of users and thousands of posts. There are many automated tools to help us with the task. This article will explain how I use rsync for Windows and sync2nas to do a nightly backup of all my data.

First you need to download the tolls for the job. You’ll need cwRsync and syn2nas.
Download cwRsync
Download sync2nas

After you download the 2 files above install cwRsync on your home computer or if you have a dev server that you work on at home to test upgrades and such install it there. The second option is what I use. I have live data from my sites on my home server. The advantages of this are enormous for upgrading and redundancy. Once you get cwRsync installed as a service on your home box you’ll need to configure it. The default will install to C:\cwRsyncServer. Head into that dir and read the documentation to get familiar with it. Once you have read the documentation it’s time to edit rsyncd.conf to allow connections from your server.

The basic rsyncd.conf will look something like this:

use chroot = false
strict modes = false
hosts allow = *
log file = rsyncd.log
pid file =
secrets file = rsyncd.secrets
# Module definitions
# Remember cygwin naming conventions : c:\work becomes /cygwin/c/work
path = /cygdrive/c/work
read only = false
transfer logging = yes

What you want to do is create a section to allow your server to connect to your home computer to transfer your data.

You’ll want to edit rsyncd.conf to add this. Make sure you change the paths I use to reflect the real paths. You could just create the directories I use and leave it if you wish. In any case you’ll have to set a username and password.

path = /cygdrive/c/backups/remote
comment = Local Backups
read only = false
transfer logging = yes
auth users = YourUsername
secrets file = rsyncd.secrets
read only = false
list = false
hosts allow = your server

In the above change connection name, and username to whatever you want. If you use the paths above then create C:\backups and C:\backups\remote. If you are using Windows XP then no permissions need to be set on those directories. If you are using Windows 2003 Server you need to set permissions on C:\backups to allow NETWORK read, write and modify on the directory and all directories below it.

You notice the rsyncd.secrets line. This is where the username password information is found. Open Notepad and add


to it. Now save it as rysncd.secrets and put it in the same dir as you rsyncd.conf file.
You can add as many sections like the one you created for different websites. Once you get the hang of using it you’ll be able to backup everything from your sites.
One last thing to do to set up cwRsync.
Go to Start > All Programs > Administartive Tools.
Click on Services to open Services manager. Scroll down the list on the right and look for RscycServer.
Right click the service and select Properties. Change Startup type from Manual to Automatic. Use the dropdown to change this. Once you change it close the properties box and click apply. The service will not start whenever Windows starts.

Now you’re done with the client side of the install. cwRsync is now ready to accept backups from the server. All you have to do now is install sync2nas on the server.

Transfer the sync2nas installer that you downloaded to the server and run the installer. It will install sync2nas in C:\sync2nas. Head into C:\sync2nas and right click sync2nas.exe and select pin to start menu. This makes it easy to open snyc2nas.
Click Start > syn2nas.exe to start to program. You’ll get what look like Windows Explorer with the left pane showing you drives and folders. Below that you’ll see the server connection boxes. In the Appliance or Virtual IP box add the IP of your home computer. Make sure you open port 873 on your firewall and/or router so sync2nas can access your home box. If the input boxes are greyed out go to the menu on top and in Advanced menu click enable username field. After you add the IP fill out the other boxes. The share name is the [ConnectionName] in your ryncd.conf. Add that name without the []. Remote folder is the folder you want the data stored in. You already have your backup folder set in rsyncd.conf. If you leave this blank it will create a directory in your backup dir the same name as the dir you are backing up. For instance if you are backing up a mysql database called mydb it will create mydb in C:\backups\remote. While this is ok I like to organize things. I set Remote Folder to data for database backups and sites for files backups. Now that you have that set you’ll add your username and password. They are the ones in your ryncd.secrets file.

Now you’ll want to choose which database to backup. In the left pane navigate to your mysql data directory. If you want to back up the whole data dir then just click the >> button between the 2 panes and it will add it to the list. If you want to add just a couple databases then click + and wait for the dir to open. Then just click and add the databses you want to backup.

The last step is to create a scheduled task to run the backup. You do that in the Source Replication Task Schedule. This pretty much self explanatory. One you have the scheduled task created add you administartor account username and password and click apply. A little message at the bottom will tell you the task was created. Now would be a good time to do the initial backup. The first one takes a bit of time since it has to transfer all the data. Subsequent backups don’t take as long. To backup right away go to File meu > Replicate Once Immediately. It will take a few minutes for the task to start as it gathers file information. Once it starts a command box will popup and the transfer will begin. When it completes, could take an hour or 2 depending on the size of the files being transfered, the box will close.

Once you input the server IP, username and such you might want to ping your home box to make sure it accepts connections. To do that hit the Ping button. At the bottom if it says server is alive and acceptin connections then you are ready to go. If it errors then check that you have port 873 open to your home box and that the RsyncServer is running.

Now that you have cwRsync setup on your home network you can also backup you Linux servers to it using rsync which is built in to Linux. Instructions to do that are beyond the scope of this article, but a quick Google search should lead you to a tutorial on how to set up rsync on your Linux server.

That’s all. Now you’ll never have to worry about losing any data.

Leave a Reply

4 Comments on "Backing Up Your Data With cwRsync and sync2nas"

Notify of