Rsync Daemon Mode with LuckyBackup
I wanted to setup a full backup solution of my home server with my documentation wiki. At the base level rsync looks like the best candidate and for the client GUI I selected LuckyBackup which is included in the standard Ubuntu repository. In order to consume little resources in an in house network, I selected the inetd daemon mode on the server side. If you operate via Internet, you should use SSH for security reasons.
Setup Rsync Daemon with xinetd on server side
The rsync daemon needs its own configuration file rsyncd.conf. In order to work with sudo rights a file rsyncd.secrets with the sudo password is needed. Because the rsync daemon is started via xinetd daemon, it needs the configuration file rsync.
The user and group must be root in order to get a full backup with root permission. The rsync module name is clone.
Setup of the rsync daemon Configuration file
rudi@rudiswiki:~$ cat /etc/rsyncd.conf max connections = 2 log file = /var/log/rsync.log timeout = 300 [clone] comment = clone / path = / read only = no list = yes #uid = nobody uid = root #gid = nogroup gid = root auth users = rudi secrets file = /etc/rsyncd.secrets
In order to work with root rights, you have to define the sudo password. Finally, change the permission of this file so it can't be read or modified by other users, rsync will fail if the permissions of this file are not appropriately set:
rudi@rudiswiki:~$ sudo cat /etc/rsyncd.secrets [sudo] password for rudi: rudi:<sudo-password> # from server rudi@rudiswiki:~$ sudo chmod 600 /etc/rsyncd.secrets
The xinetd.d configuration file for rsync is:
rudi@rudiswiki:~$ cat /etc/xinetd.d/rsync service rsync { disable = no socket_type = stream wait = no user = root server = /usr/bin/rsync server_args = --daemon log_on_failure += USERID }
- A network service number must be defined, which is usually provided by the installation:
rudi@rudiswiki:~$ cat /etc/services | grep rsync rsync 873/tcp rsync 873/udp
Connecting to the rsync daemon
To connect to rsync when it is running as a daemon, instead of use a colon as we do when using SSH, we need to use a double colon, followed by the module name, and the file or folder that we want to copy or synchronize, we can use:
rsync -rtv user@host::module/source/ destination/ e.g. rudi@rudiswiki:~$ sudo rsync -rtv rudi@192.168.17.72::clone /clone/
Just remember that the user that appears there is one of the users that we defined in /etc/rsyncd.secrets and not a user of the host computer. What is a bit tricky are the passwords, the first is the sudo password, the second is the remote password.
rsync version
rudi@rudiswiki:~$ rsync --version rsync version 3.0.7 protocol version 30 Copyright (C) 1996-2009 by Andrew Tridgell, Wayne Davison, and others. Web site: http://rsync.samba.org/ Capabilities: 64-bit files, 64-bit inums, 32-bit timestamps, 64-bit long ints, socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace, append, ACLs, xattrs, iconv, symtimes
LuckyBackup 0.4.4
In order to backup the rudiswiki hard disk RAID1 array to a backup hard disk via network, the program LuckyBackup with underlaying rsync is used. Then you have a third independent hard disk, just in case of a dramatic failure.
Note: Version 0.3.5 which comes with Ubuntu 10.04.1 has a problem, which locks the program if folder /proc is selected for exclusion. Version 0.4.4 does not have that problem.
The benefit of luckyBackup is, that you can activate a simulate (Dry) mode and see what is in the protocol window. That can help to avoid misunderstandings. The setup for a remote rsynch connection via network is very good made. Also an extensive manual is available on line, see at the links.
On the server rsync is setup as a daemon, started via xinetd network service.
If the third 250 GB spare hard disk has set the raid mark in the directories, it will not be mounted automatically in Ubuntu, but it make swapping with a RAID1 hard disk easier. In order to use luckyBackup you have to mount the partitions before use, if it is not auto mounted.
# If there is not already a destination directory provided, it must be created. $ sudo mkdir /media/MX250 # mount the system disk, adopt /dev/sdxn to your system $ sudo mount -t ext3 /dev/sdc3 /media/MX250 # mount the boot partition $ sudo mount -t ext2 /dev/sdc1 /media/MX250/boot
For documentation purpose I will list all Task properties, in case of a remote rsync, Source has the rsync module name of the server setup:
Task Name: clone_rudiswiki Type: Backup the entire directory (by name) Source: clone Destination: /media/MX250 Advanced properties: Exclude Templates: Temporary folders System mount folders Backup files # System folders - NO MARK Cache folders lost+found Trash Exclude User Defined: /cdrom/* /home/rudi/.gvfs /dev /sys /proc /var/lock /var/cache /var/run Remote - Use remote host: Source User: rudi @Host: 192.168.17.72 remote module: yes rsync password file: /etc/rsyncd.secret Command options: Preserve ownership, times # Delete files on destination - NO MARK Preserver permissions Recurse into directories Preserve symlinks Skip newer destination files Preserve device, special files Also execute: nothing Validate: Command to execute; rsync -h --progress --stats -r -tgo -p -l -D --update --exclude=**/*tmp*/ --exclude=**/*cache*/ --exclude=**/*Cache*/ --exclude=**~ --exclude=/mnt/*/** --exclude=/media/*/** --exclude=**/lost+found*/ --exclude=**/*Trash*/ --exclude=**/*trash*/ --exclude=/cdrom/* --exclude=/home/rudi/.gvfs --exclude=/dev --exclude=/sys --exclude=/proc --exclude=/var/lock --exclude=/var/cache --exclude=/var/run --password-file=/etc/rsyncd.secrets rudi@192.168.17.72::clone /media/MX250/
Links
http://www.jveweb.net/en/archives/2011/01/running-rsync-as-a-daemon.html
http://ubuntuforums.org/showthread.php?p=10103085
http://www.howtoforge.com/mirroring_with_rsync
http://luckybackup.sourceforge.net/manual.html
List of pages in this category:
-- RudolfReuter 2011-01-31 11:10:27
Go back to CategoryHowTo or FrontPage ; KontaktEmail (ContactEmail)