July 5, 2010

Easy backup with RSync, linux client configuration

After the basics and the server configuration here's a quick 'n' dirty example of my linux client configuration.

Each Linux client (but generically speaking a UNIX or OS/X client) only needs the rsync program installed, no additional dependencies, each linux distribution has it, just type:

~$ rsync --version
rsync version 3.0.6 protocol version 30
Copyright (C) 1996-2009 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
append, ACLs, no xattrs, iconv, symtimes

rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you
are welcome to redistribute it under certain conditions. See the GNU
General Public Licence for details.

To see if it's properly installed.

This example coming from real world is connected to an RSync server as detailed in my previous article,the script itself is not complex, it just feet my needs and I use it with cron each day, in the first section there is a configuration part for remote host setup, the second part is where the business logic resides, a little bit of logging is inserted as well

~/bin$ cat backup.rsync
# Sync sensible data of this pc to a remote rsync host

# Configuration Section, change your parameters below

# Remote host name

# RSync connection on remote host (username as well)

# Remote directory name where rsync copies will be created

# Local directory name to sync (not the whole disk...)

# RSync password for the connection (see rsyncd.secret)

# Exclude FILES
--exclude "$HOME/.Trash" --exclude "$HOME/.bittorrent" --exclude "$HOME/.dbus" --exclude "$HOME/.evolution" --exclude "$HOME/.fontconfig" --exclude "$HOME/.gnochm" --exclude "$HOME/.icons" --exclude "$HOME/.macromedia" --exclude "$HOME/.metacity" --exclude "$HOME/.mozilla" --exclude "$HOME/.mysqlgui" --exclude "$HOME/.nautilus" --exclude "$HOME/.nx" --exclude "$HOME/.python" --exclude "$HOME/.qt" "

# Business logic, don't change anything below this line
--verbose --recursive --compress --perms --owner --group --specials --stats --devices --links --times --delete $EXCLUDE_FILES "

# Exec command
RSYNC_COMMAND="`which rsync`"
DATE_BEGIN="Begin : `date`"
if [ "$1" != "" ]; then
echo "End : `date`"

echo $DATE_BEGIN >> $LOCALE_DIR/backup.rsync.log
echo "End : `date`" >> $LOCALE_DIR/backup.rsync.log

As you can see from example you can invoke this script just by typing:

~/bin$ ./backup.rsync

If you provide an additional parameter on command line you can store rsync operations in a log file (backup.rsync.log)

~/bin$ ./backup.rsync log


Glad to improve my example if someone of you wants to contribute or add something
Next article covers windows client configuration, stay tuned

Windows RSync client side configuration

Easy backup with RSync, introduction
RSync server side config on linux platform
Linux RSync client side configuration
Windows RSync client side configuration


Glad to see your comments
Andrea (Ben) Benini

Click Here!