BackupPC with Locking and WOL

Overview of our Setup

  • BackupPC is a centralized network backup solution. The backuppc daemon monitors network status of workstations, plans incremental and full backups, purges old backups from the repository.
  • The backup process, along with our other centralized support services (e.g. nightly update of work databases and files for individual developers) is taking advantage of our custom-developed a centralized locking tool. The locks prevent e.g. automatic shutdowns of serviced machines when they are being accessed by other service, or when user is physically working on the machine.
  • The /etc/backuppc/templates holds configuration templates for basic variants of our workstations/server. Config files for individual machines in /etc/backuppc are mostly symlinks to corresponding templates.
  • Our intranet web server offers a simple centralized WakeOnLAN service. It takes only a single http request with machine name. Instead of regular ping (parameter $Conf{PingPath}), our backuppc is using a simple script using the central WOL service if the machine is down.

Config Examples

Re-defining ping with WOL capability

$Conf{PingPath} = "/etc/backuppc/bin/";

For the see below.

Limiting tar and rsync to the Current Filesystem

Various machines have various mount points. We want to make sure tar and rsync do not leave the current-level filesystem.

$Conf{TarClientCmd} = '$sshPath -C -q -x -n -l root $host'
. ' /usr/bin/env LC_ALL=C $tarPath --ignore-failed-read --one-file-system'-c -v -f - -C $shareName+'
. ' --totals';
$Conf{RsyncArgs} = [
# Do not edit these!
# Add additional arguments here

Bandwidth Limiting the SSH Connections

Backup of internet-based servers at full speed would jam the download link. We are using the trickle tool. Only specific servers have this directive in their config file.

# bandwidth limiting: 2000kB=16Mb down, 300kB=2.4Mb up
$Conf{TarClientCmd} = '/usr/bin/trickle -s -u 300 -d 2000 $sshPath -C -q -x -n -l root $host'
. ' /usr/bin/env LC_ALL=C nice $tarPath --one-file-system -c -v -f - -C $shareName+'
. ' --totals';

Limiting I/O Load on Backed-up Machines

Heavily loaded machines cannot afford to hand its full I/O capacity to the backup job. We are using the ionice tool.

$Conf{TarClientCmd} = '$sshPath -C -q -x -n -l root $host'
. ' /usr/bin/env LC_ALL=C ionice -c 2 -n 7 $tarPath --ignore-failed-read --one-file-system -c -v -f - -C $shareName+'
. ' --totals';
$Conf{RsyncClientCmd} = '$sshPath -q -x -l root $host ionice -c 2 -n 7 $rsyncPath $argList+';

Templating the Configuration Files

We have categorized the backed-up machines based on their purpose and characteristics. Each purpose/characteristics has its specific configuration in /etc/backuppc/templates directory. E.g. holds configuration forlinux machines in general:

$Conf{XferMethod} = 'tar';
$Conf{TarShareName} = ['/','/boot'];
# vetsi timeout...
$Conf{ClientTimeout} = 7*3600;

$Conf{BlackoutBadPingLimit} = 72;
$Conf{BlackoutGoodCnt} = 1;

$Conf{BackupFilesExclude} = {
'/' => [ '/proc', '/tmp', '/sys',
'/var/run', '/var/lock', '/var/cache/apt/archives',
'/cdrom', '/mnt/cd', '/mnt/cdrom',
'.In*', '.x*', '.X*',
'/var/lib/mysql', '/var/lib/sendmail',

Our template provides configuration for our development machines with standardized layout of raid arrays and standardized excluded directories (in fact holding millions of files we do not want to backup)

push @{$Conf{TarShareName}}, '/mnt/raid/';
push @{$Conf{BackupFilesExclude}{'/mnt/raid/'}}, '/mysql*',
# larger timeour
$Conf{ClientTimeout} = 10*3600;

These features are combined to yield the desired functionality. Regular linux non-development workstations are safely halted after the backup finishes-

# Standard linux workstation, only halting

do "/etc/backuppc/templates/";

$Conf{DumpPostUserCmd} = '$sshPath -q -x -l root $host /opt/ivitera_scripts/bin/ backup';

Linux development workstations have more specific requirements –

## config for devel PC - data in /mnt/raid
do "/etc/backuppc/templates/";
do "/etc/backuppc/templates/";

Linux servers are simple. Yet we provide a separate template for the servers which can be modified in the future –

# Standard linux server, only locking

do "/etc/backuppc/templates/";

Linux development servers build on top of this template, but share the development feature with development workstations –

## config for devel server - data in /mnt/raid
do "/etc/backuppc/templates/";
do "/etc/backuppc/templates/";

We have a windows cygwin workstation too –

Conf{XferMethod} = "tar";
$Conf{TarShareName} = ['/cygdrive/c'];

$Conf{BackupFilesExclude} = [
'/Program Files',
'/System Volume Information',
'/Documents and Settings/All Users/DRM',
'/Documents and Settings/*/NTUSER.DAT',
'/Documents and Settings/*/ntuser.dat.LOG',
'/Documents and Settings/*/Local Settings/Data aplikací/Microsoft/Windows/UsrClass.dat',
'/Documents and Settings/*/Local Settings/Data aplikací/Microsoft/Windows/UsrClass.dat.LOG',
'/Documents and Settings/*/Data aplikací/Mozilla/Firefox/Profiles/*/parent.lock',
'/Documents and Settings/*/Data aplikací/Thunderbird/Profiles/*/parent.lock',
'/Documents and Settings/*/Data aplikací/Skype'

$Conf{ClientTimeout} = 7*3600;

# locks - functional only for linux/cygwin
$Conf{DumpPreUserCmd} = '$sshPath -q -x -l root $host /opt/ivitera_scripts/bin/ backup';
$Conf{DumpPostUserCmd} = '$sshPath -q -x -l root $host /opt/ivitera_scripts/bin/ backup';

Configuration files for individual machines in /etc/backuppc are either directly symlinks to their corresponding templates in /etc/backuppc/templates, or include the template and add/modify some settings:

orfeus:/etc/backuppc# ls -l
lrwxrwxrwx 1 root root 49 2010-09-17 12:18 -> /etc/backuppc/templates/
-rw-r--r-- 1 root root 69407 2011-05-31 08:23
-rw-r--r-- 1 root root 27 2011-08-23 14:05
lrwxrwxrwx 1 root root 50 2010-09-17 12:17 -> /etc/backuppc/templates/
lrwxrwxrwx 1 root root 44 2010-09-17 12:23 -> /etc/backuppc/templates/
-rwxr-xr-x 1 root root 169 2010-11-02 16:22
-rw-r--r-- 1 pavel www-data 311 2010-11-02 16:21
drwxr-xr-x 1 root root 4096 2011-08-23 21:58 templates

Where our main devel server

do "/etc/backuppc/templates/";
# huge timeout...
$Conf{ClientTimeout} = 5*24*3600;
# plus dumping SQL databases before the backup - must be a single script since backuppc does not accept multiple commands here 🙁
$Conf{DumpPreUserCmd} = '/etc/backuppc/';

WOL-enabled ping

The following script takes advantage of our central WOL tool

#! /bin/bash


echo "$1 $2 $3" >> /tmp/wolping.log

source /etc/ivitera/

if ! $PING $ARG1 $ARG2 $WAKEHOST; then
# functions defined in
if [ "$WOL_RES" = "FAIL" ]; then
exit 1
sleep 5m
$PING $ARG1 $ARG2 $WAKEHOST || exit 1

exit 0


export WOL_RES
function fwol {
if /usr/bin/wget -O - "$TO_WAKEUP" | grep -q "ERROR" ; then
echo "WOL failed"
echo "WOL OK"

export PING_RES
function fping {
if /bin/ping -c 10 -l 4 $TO_PING 2>/dev/null >/dev/null ; then
echo "$MACHINE running"
echo "$MACHINE not running"

This entry was posted in IT Infrastructure. Bookmark the permalink.
Tags , ,

Comments are closed.