Categories: How-Tos

Automate Backups on Network

Rsync is a small program that you can use to back up data from computers on to a central network server. The good thing about Rsync is that it syncs data for back up without affecting the network bandwidth. It performs incremental backup, which means, if a backedup file already exists on the central server, it copies only the difference between the two files, thereby not affecting network traffic (on LANs or WANs). Rsync can sync data even over a modem connection. It also creates a mirror of your hard drive on the central server so that you can recover your data if your hard drive crashes. 

RSync is a Linux program that has been ported to Windows and is also available for various UNIX platforms. This article will guide you on setting up a central network backup unit for use with Windows clients. 


Set up server
When we set up Rsync, we used a Linux box running PCQLinux 8.0. You need to first create accounts for all the Windows and Linux users on your network, who would be backing up their data on this server. Next, you need to ensure that it has Samba running to provide file services to all the Windows clients. It must also have a NetBIOS name, say Remote1. Finally, remember to make sure that Samba is sharing the home directories of all the users you created on this server. 


Set up Windows clients
You’ll need to apply the following process to all the Windows clients that would be using Rsync on your network. It works on all the popular Windows versions (9x/ 2000/XP). 

First, install Cygwin (on PCQ Essential CD, July 2003) on each Windows client by running the setup.exe file. Next, copy the rsync.zip file from this month’s CD to this machine’s local drive (say c:\). Unzipping this file will create a folder C:\rsync. Make sure each Windows machine can access the Remote1 server. 

Now, open a command window from the Windows machine and go the C:\rsync folder. Here, edit the rsetup.bat file. Find the entry USERNAME=myusername and replace myusername with the user you created for this Windows client on Remote1. Save the file and enter rsetup at the command prompt to install Rsync . This will also set the required path variables for


Run RSync
To run Rsync from the Windows machine, open the command window and go to the C:\rsync folder. Then, run the following command to take a backup or sync data: 

C:\rsync>rsync251-2.exe -e ssh -av –delete “/cygdrive/c/ remote1:data 
After running this command, you will be prompted for a password. Give the password corresponding to the user name on remote1. The above command will back up the entire C drive to the machine named remote1 in the folder named data under the user’s home directory.


Recover data 
You can recover data from the server by simply browsing it from the Windows Network Neighborhood and copying the files back to your system. Or, you can use a command line to retrieve the data as follows: 

C:\rsync>rsync251-2.exe —e ssh —a remote1:/data/ .

where, the final (.) is your local destination. 


Automate back up 
You can automate backup and sync processes by writing a sequence of commands in a batch file and setting the Windows
Scheduler to execute this. 

This program thus helps to sync data over the network without affecting the network bandwidth.

Sanjay Majumder

RSYNC in Linux

You can backup from a Linux machine in exactly the same manner as you would from a Windows machine. Generally, Rsync is installed by default in PCQLinux or RedHat Linux, so you don’t have to install it separately. Just open a terminal window on the Linux machine from where you want to take the backup and run the following command:

#rsync -e ssh -av —delete “/” remote1:data1

Here the syntax is

rsync -e ssh —av —delete “[SOURCE]” [CENTRAL SERVER]:[DESTINATION FOLDER] 

The above command will copy all data present in the root directory (“/”) of your Linux machine to a folder called data1 in the users directory of the Rsync server.

You also recover data from a Linux machine in the same way as you would from a Windows machine. Just run the following command:

#rsync —e ssh —a remote1:data1.

That should restore your machine.

PCQ Bureau: