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/
Capabilities:
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
#!/bin/bash
# Sync sensible data of this pc to a remote rsync host
#
# Configuration Section, change your parameters below
# Remote host name
REMOTE_HOSTNAME=myfavoritenas
# RSync connection on remote host (username as well)
REMOTE_SYNC_POINT=array1_backup
# Remote directory name where rsync copies will be created
REMOTE_DIR=linux_client_host
# Local directory name to sync (not the whole disk...)
LOCALE_DIR=$HOME
# RSync password for the connection (see rsyncd.secret)
RSYNC_PASSWORD=idonttellmypasswdtoyou
# Exclude FILES
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
MY_RSYNC_OPTIONS="
--verbose --recursive --compress --perms --owner --group --specials --stats --devices --links --times --delete $EXCLUDE_FILES "
# Exec command
RSYNC_COMMAND="`which rsync`"
export RSYNC_PASSWORD
DATE_BEGIN="Begin : `date`"
if [ "$1" != "" ]; then
$RSYNC_COMMAND $MY_RSYNC_OPTIONS $LOCALE_DIR/ $REMOTE_SYNC_POINT@$REMOTE_HOSTNAME::$REMOTE_SYNC_POINT/$REMOTE_DIR
echo $DATE_BEGIN
echo "End : `date`"
else
$RSYNC_COMMAND $MY_RSYNC_OPTIONS $LOCALE_DIR/ $REMOTE_SYNC_POINT@$REMOTE_HOSTNAME::$REMOTE_SYNC_POINT/$REMOTE_DIR > /$LOCALE_DIR/backup.rsync.log 2>&1
echo $DATE_BEGIN >> $LOCALE_DIR/backup.rsync.log
echo "End : `date`" >> $LOCALE_DIR/backup.rsync.log
fi
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
Next:
Windows RSync client side configuration
Steps:
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