Logo

Backup with BackupPC

I used to backup my systems with "dump" for a long time. When I decided to switch over to ReiserFS "dump" was no longer an option. I then used "amanda" for a couple of years in corporation with a tape device. Since USB harddisks had become cheaper and cheaper, I no longer wanted to rely on slow and expensive tape devices. In order to find a new backup solution, I conducted an evaluation with a winner, finally: BackupPC

Home: http://sourceforge.net/projects/backuppc

BackupPC is an excellent, freely available backup software, written in Perl, with a well arranged web-based front end. It runs on Linux or any UNIX based operating system. No specific client software is necessary to perform client backups on the forenamed operating systems, including windows. BackupPC extracts backup data via SMB using Samba. Tar can be used natively or over ssh/rsh/nfs, or rsync. It is published under the GNU General Public License.

 

Main features

  • Pooling scheme minimizes disk storage and disk I/O. Identical files across multiple backups of the same or different PCs are stored only once resulting in substantial savings in disk storage and disk I/O
  • Optional compression support further reducing disk storage
  • Can backup to internal / external hard disk, tape devices and so on
  • No client-side software is needed. Smb is used on Win clients, tar on Linux clients. Rsync is supported beginning with version 2.0.0
  • The web (http/cgi) user interface allows to view log files, configuration, current status and allows users to initiate and cancel backups and browse and restore files from backups
  • Full set of restore options, including direct restore (via smbclient, tar, or rsync/rsyncd) or downloading a zip or tar file. Single files can be downloaded from any backup directly from the CGI interface
  • Supports mobile environments with DHCP addresses such as laptops that are only intermittently connected to the network
  • Flexible configuration parameters (system-wide or on a per-PC basis), e.g. parallel backups, shares to backup not backup, schedules for full and incremental backups, email reminders to users
  • Periodic email reminders to users if their PC has not recently been backed up

 

Requirements

  • A linux, solaris, or unix based server with a substantial amount of free disk space and a proficient CPU. Both values determine how many simultaneous backup can be run on the machine
  • Perl version 5.8.0 or later
  • A mod_perl enabled apache (webserver)
  • Perl modules Compress::Zlib, Archive::Zip and File::RsyncP
  • Smb tools for backup of windows hosts
  • Version 1.13.7 at least of tar for backup of Linux / UNIX machines
  • Version 2.6.3 at least on each client machine if you want to use rsync. For BackupPC to use Rsync you will also need to install the perl File::RsyncP module

 

Installation

I don't want to go to much into details here. There is an excellent online documentation and instructions that come with the tarball. There are some prerequisites (see above) prior to installation. Some specifics will be covered below.

 

Slackware specific constraints

At the time I installed BackupPC for the first time and wrote installation instructions for myself, Slackware offered no mod_perl enabled apache web server. If this still is true, you are on your own - I stronlgy recommend to use a perl enabled apache web server. Be aware that instructions below are for apache 1.3.xx numbered web servers.

In addition, apache should run under a specific _BackupPC_ user (see installation instructions). If your apache should serve other things, this might interfere with your security precautions, especially when serving for external access. To meet these concerns, I recommend to run a dedicated apache (httpd) instance with its own configuration file. To do so you can use the "-f" and "-d" options - see apache online documentation and man page. Or you can build a special apache Slackware package by following the instructions and using the layout file below. Up to you - several roads lead to Rom.

 

Special apache layout

I use a special apache layout file for my dedicated BackupPC apache - adapt the path to whatever fits your needs. The file is called "config.layout.slack".

 

# Layout for Slackware Linux
<Layout Slackware>
prefix: /var/www/backuppc_apache
exec_prefix: $prefix
bindir: $exec_prefix/bin
sbindir: $exec_prefix/sbin
libexecdir: $exec_prefix/libexec/apache
mandir: $prefix/man
sysconfdir: /var/www/backuppc_apache/etc/apache
datadir: /var/www/backuppc_apache
iconsdir: $datadir/icons
htdocsdir: $datadir/htdocs
cgidir: $datadir/cgi-bin
includedir: $prefix/include/apache
localstatedir: /var/www/backuppc_apache
runtimedir: $localstatedir/run
logfiledir: $localstatedir/log/apache
proxycachedir: $localstatedir/cache/proxy
</Layout>

 

Perl enabled apache web server

1. Get the latest mod_perl source code

2. Get the latest apache source from a Slackware mirror. Use the latest version that fits your Slackware release. You will find the apache sources in tree "n" - for an explanation of the Slackware tree see the opening article in the Slackware section. If there had been security issues with apache, the latest version could also be in the "patches" directory.

3. Copy the mod_perl tar.gz file in the local apache source tree. You should now have a variety of files in the local apache source tree, correspondingly:

  • apache.SlackBuild
  • apache.dbm.diff.gz
  • apache_1.3.34.tar.gz
  • apache_1.3.34.tar.gz.asc
  • config.layout.slack
  • mm-1.3.1.tar.gz
  • mod_perl-1.0-current.tar.gz
  • mod_perl-1.29/
  • mod_ssl-2.8.25-1.3.34.tar.gz
  • slack-desc

 

4. Extract apache and mod_perl archive

5. Configure mod_perl with the string shown below. Be sure to adapt the apache version as necessary. After "configure", type "make". You do not have to install "make install" mod_perl. In case of doubt check for the presence of a perl directory in the apache source "./src/modules/". There should be a perl subdirectory with files in it.

 

perl Makefile.PL \
APACHE_SRC=../apache_1.3.34/src \
DO_HTTPD=1 \
USE_APACI=1 \
PREP_HTTPD=1 \
EVERYTHING=1

 

6. Re-create the apache archive (apache_1.3.34.tar.gz). This archive contains now the mod_perl files for your mod_perl enabled webserver.

7. Insert the following string in the "apache.SlackBuild" file:

 

--activate-module=src/modules/perl/libperl.a

 

Change manual patch accordingly.

The modified configure section goes like this:

 

./configure \
--with-layout=Slackware \
--enable-module=most \
--enable-shared=max \
--manualdir=/var/www/backuppc_apache/manual \
--enable-rule=eapi
--activate-module=src/modules/perl/libperl.a

 

8. Copy modified "apache.SlackBuild" and "config.layout.slack" in the local apache source tree (of not already done so).

9. Execute ./apache.SlackBuild - this creates the mod_perl enabled apache web server in /tmp. Install this package with "installpkg"

10. Adjust httpd.conf to use with BackupPC. See special section in this article.

11. Fire up apache to use with BackupPC.

 

Apache configuration file

Go trough your httpd.conf file and adjust as needed. Below some options you definitely want to take care of.

 

ServerRoot "/var/www/backuppc_apache"

PidFile /var/www/backuppc_apache/run/httpd.pid

 

The port you want to run apache under. Only specify if not the default port.

 

Port 10001

 

The user and group to run apache under.

 

User amanda
Group nobody

 

The document root. Make sure to change all paths throughout the hole configuration file accordingly.

 

DocumentRoot "/var/www/backuppc_apache/htdocs"

 

Location of log files.

 

ErrorLog /var/www/backuppc_apache/log/apache/error_log
CustomLog /var/www/backuppc_apache/log/apache/access_log common

 

ScriptAlias /cgi-bin/ "/var/www/backuppc_apache/cgi-bin/"

 

<Directory "/var/www/backuppc_apache/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>

 

And finally, include the following at the end of your config file.

 

# mod_perl Setup
<IfModule mod_perl.c>
PerlModule Apache::Registry
PerlTaintCheck On
<Location /cgi-bin/BackupPC_Admin> # <--- change path as needed
SetHandler perl-script
PerlHandler Apache::Registry
Options ExecCGI
PerlSendHeader On
</Location>
</IfModule>

 

BackupPC configuration file

The file is called "config.pl". I do not want to go trough the file here, this would be beyond the scope of this article. Just make sure you define which hosts and what to backup. You should consider to define your own small backup strategy and write it down. In this context, you should be confident with:

  • Backup type (full, incremental, differential ...)
  • Hosts to backup
  • Files and directories to include / exclude
  • Backup intervals
  • Data generations (how long you want your backups be available
  • File generations (how many different versions of a file should be included in your data pool
  • Recovery strategy
  • ...

The options are generally quite good documented in the config file itself. If that's not enough, go to the BackupPC website.

 

BackupPC startup script

This is the BackupPC init script I use. Please adapt:

  • [BackupPC_User] with the name of the user you run apache and BackupPC under
  • [/path/to/BackupPC] with the path to the BackupPC executeable

 

#!/bin/sh
#
# Oliver Brunner / 231005
#
# DESCRIPTION
#
# BackupPC init script for for Slackware.
#
#
start() {
#
su BackupPC_User -c "/path/to/BackupPC -d"
}

stop() {
/usr/bin/pkill -f "/path/to/BackupPC -d"
}

restart() {
stop
start
}

reload() {
/usr/bin/pkill -1 -f "/path/to/BackupPC -d"
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
reload)
reload
;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
esac

exit $?

 

Glossary

Full Backup

A full backup is a complete backup of a share. BackupPC can be configured to do a full backup at a regular interval

 

Incremental Backup

An incremental backup is a backup of files that have changed since the last successful full or incremental backup

 

Partial Backup

When a full backup fails or is canceled, and some files have already been backed up, BackupPC keeps a partial backup containing just the files that were backed up successfully

 

Identical Files

BackupPC pools identical files using hardlinks. Identical files are files with identical contents, not necessary the same permissions, ownership or modification time. Two files might have different permissions, ownership, or modification time but will still be pooled whenever the contents are identical. This is possible since BackupPC stores the file meta-data (permissions, ownership, and modification time) separately from the file contents

 

Backup Policy

Based on your site's requirements you need to decide what your backup policy is. BackupPC is not designed to provide exact re-imaging of failed disks.

 

Screenshots

Summary Overview

summary

 

Browse Backups

browse backups

 

Restore Options

restore options

 

Log Files

log files