Rsync - DeltaCopy

Efficient and Secure File Copies


rsync and rsync daemon

rsync is a program that behaves in much the same way that rcp (remote copy) does, but has many more options and uses the rsync remote-update protocol to greatly speed up file transfers when the destination file already exists. The rsync remote-update protocol allows rsync to transfer just the differences between two sets of files across the network link, using an efficient checksum-search algorithm described in the technical report that accompanies this package. Rsync can thus be used as an efficient file copy / backup mechanism.

The fast approach to rsync is to have rsync installed on two hosts, which will allow the two hosts to rsync files between one another. To this end, rsync uses ssh (or an other remote shell application) as transport channel, which means that the destination host needs to be running an ssh server (such as open-ssh server).

rsync can also be run in daemon mode, meaning that rsync itself will run continuously (in daemon mode) and listen for connections from rsync on other hosts, eliminating the need for an ssh server or ssh transport. This may be a preferred arrangement for a backup server.

rsync is a Linux tool, so this would limit you to backups between linux hosts. However, "DeltaCopy" offers a rsync-based DeltaCopy server and DeltaCopy client for Windows, allowing you to run an rsync server on a Windows host as well, or allowing you to rsync from a Windows system to either an rsync daemon on Linux, or a DeltaCopy server on a Windows server. In mixed environments with Windows servers alongside Linux servers (eg with Samba File Sharing and Windows File Sharing combined), this allows for unified rsyncing between any host.

Your options are then as follows

From (source)To (target)Solution
Linux/UNIX Linux/UNIX use rsync on both machines, either over ssh or with rsync in daemon mode

Windows Linux/UNIX source machine : DeltaCopy client
target machine : rsync : either run rsync as a daemon or use it via SSH.
DeltaCopy client has built-in ssh-client support
Windows Windows source machine : DeltaCopy Client
target machine : DeltaCopy Server

Linux/UNIX Windows source machine : rsync
target machine : DeltaCopy Server. This is equivalent to rsync in daemon mode; rsync will connect via TCP/IP.
Since there is no built-in SSH on Windows, you cannot use rsync over SSH in this scenario, unless by using a third party SSH server for Windows.


Case 1: rsync (backup) of windows clients to a Windows server

This is the primary use of DeltaCopy, and the DeltaCopy website has detailed instructions on how to set this up. It's simple, really : run the DeltaCopy setup.exe on both client and server machines - the setup installs both server and client software.

Then, run the server, and configure backup jobs and schedules on the clients.

caveats:

Case 2: rsync (backup) of windows clients to a Linux server

note that this 'Windows clients" could actually be Windows servers backing up their configuration, user files, ... to disk on a Linux machine. also note that this is a file transfer without using samba or another filesharing mechanism

A/ setting up rsync daemon on linux

you need to have rsync installed and will run it with
rsync --daemon, which will use a configuration file /etc.rsyncd.conf that doesn"t exist yet - you need to create it

create a directory that will contain your backups, eg /srv/backup

Then, create /etc/rsyncd.conf, looking roughly like this :

		use chroot = yes
		pid file = /var/run/rsyncd.pid

		[backuptest]
        		path = /srv/backup
        		comment = LAN backup test area
        		read only = false
	

The "[backuptest]" section is called a module, and corresponds to a virtual directory definition in DeltaCopy Server.

Outside the module definitions (sections) are global configuration options, that will apply to all modules.

rsync daemon by default chroots to the target path for security reasons. This requires it to be started as root, but it it can use an alternative uid of guid to access "the module", i.e. the target specification in rsync. You can specify a user and group account or keep the defaults (nobody, nogroup). This does mean that these accounts need adequate access to the target directory (eg write access for file uploads)

			~# chown nobody:nogroup /srv/backup/
			~# ls -ld /srv/backup/
			drwxr-xr-x 2 nobody nogroup 4096 2008-09-13 08:53 /srv/backup/
	

rsync daemon modules are read-only by default, so to allow writes by clients, you need to set read only = false in the module definition.

For troubleshooting, look in syslog ( grep rsync /var/log/syslog)

To start rsync in daemon mode, you can run it from a shell. To stop the daemon, you need to kill it, so you need to find the process ID. You can find this from /var/run/rsyncd.pid or ps -e |grep rsync, or install psmisc and use the killall utility.

	#start
		rsync --daemon

	#stop
		kill $(cat /var/run/rsyncd.pid) 
	

To run a real backup server, you want to ensure this service is always running. You can do this with an inetd or xinetd configuration, or by init startup scripts. On debian 4, you need to enable the rsync daemon in /etc/defaults/rsync, where you also choose whether or not to use inetd.

If a startup script isn't present on your distribution (look for /etc/init.d/rsync or something similar), it's easy to create one yourself.

Sample startup script : /etc/init.d/rsync

	#!/bin/bash
	## start stop service script for rsync daemon
		
		case $1 in
			start)
				echo -n "starting rsync in daemon mode ... "
				rsync --daemon && echo "  success"
				ps -e |grep rsync
			;;
			stop)
				echo "stopping rsync daemon"
				kill $(cat /var/run/rsyncd.pid)
				
			;;	
			restart)
				$0 stop
				$0 start
			;;
			*)
				echo "usage: $0 start|stop|restart"
			;;
		esac
	

To have the startup script run at startup, you need to enable it for the appropriate runlevels :

	
		#create init scrips
		update-rc.d rsyncd S 99 defaults . K 99 defaults .
	

B/ setting up a windows client

as before (see case 1). The virtual directory that you backup to = the section ("module") defined in rsyncd.conf

Backup to tape

rsync can currently not do backups to tape. Obviously, backup to disk, then to tape should be possible if you let the backup server handle the "to tape" part.


Resources


Koen Noens
September 2008