BackupPC


BackupPC Introduction

This documentation describes BackupPC version 2.0.2, released on 6 Oct 2003.

Overview

BackupPC is a high-performance, enterprise-grade system for backing up Linux and WinXX PCs, desktops and laptops to a server's disk. BackupPC is highly configurable and easy to install and maintain.

Given the ever decreasing cost of disks and raid systems, it is now practical and cost effective to backup a large number of machines onto a server's local disk or network storage. For some sites this might be the complete backup solution. For other sites additional permanent archives could be created by periodically backing up the server to tape.

Features include:

Backup basics

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 (often weekly). BackupPC can also be configured to keep a certain number of full backups, and to keep a smaller number of very old full backups.

Incremental Backup
An incremental backup is a backup of files that have changed (based on their modification time) since the last successful full backup. For SMB and tar, BackupPC backups all files that have changed since one hour prior to the start of the last successful full backup. Rsync is more clever: any files who attributes have changed (ie: uid, gid, mtime, modes, size) since the last full are backed up. Deleted and new files are also detected by Rsync incrementals (SMB and tar are not able to detect deleted files or new files whose modification time is prior to the last full dump.

BackupPC can also be configured to keep a certain number of incremental backups, and to keep a smaller number of very old incremental backups. (BackupPC does not support multi-level incremental backups, although it would be easy to do so.)

BackupPC's CGI interface ``fills-in'' incremental backups based on the last full backup, giving every backup a ``full'' appearance. This makes browsing and restoring backups easier.

Identical Files
BackupPC pools identical files using hardlinks. By ``identical files'' we mean 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. See Limitations for more information. However, the addition of tar transport for linux/unix clients, plus full support for special file types and unix attributes in v1.4.0 likely means an exact image of a linux/unix file system can be made.

BackupPC saves backups onto disk. Because of pooling you can relatively economically keep several weeks of old backups. But BackupPC does not provide permanent storage to tape. Other Open Source applications can do this by backing up BackupPC's pool directories to tape.

At some sites the disk-based backup will be adequate, without a secondary tape backup. This system is robust to any single failure: if a client disk fails or loses files, the BackupPC server can be used to restore files. If the server disk fails, BackupPC can be restarted on a fresh file system, and create new backups from the clients. The chance of the server disk failing can be made very small by spending more money on increasingly better RAID systems.

At other sites a secondary tape backup will be required. This tape backup can be done perhaps weekly from the BackupPC pool file system.

Resources

BackupPC home page
The BackupPC Open Source project is hosted on SourceForge. The home page can be found at:
    http://backuppc.sourceforge.net

This page has links to the current documentation, the SourceForge project page and general information.

SourceForge project
The SourceForge project page is at:
    http://sourceforge.net/projects/backuppc

This page has links to the current releases of BackupPC.

Mail lists
Three BackupPC mailing lists exist for announcements (backuppc-announce), developers (backuppc-devel), and a general user list for support, asking questions or any other topic relevant to BackupPC (backuppc-users).

You can subscribe to these lists by visiting:

    http://lists.sourceforge.net/lists/listinfo/backuppc-announce
    http://lists.sourceforge.net/lists/listinfo/backuppc-users
    http://lists.sourceforge.net/lists/listinfo/backuppc-devel

The backuppc-announce list is moderated and is used only for important announcements (eg: new versions). It is low traffic. You only need to subscribe to one of backuppc-announce and backuppc-users: backuppc-users also receives any messages on backuppc-announce.

The backuppc-devel list is only for developers who are working on BackupPC. Do not post questions or support requests there. But detailed technical discussions should happen on this list.

To post a message to the backuppc-users list, send an email to

    backuppc-users@lists.sourceforge.net

Do not send subscription requests to this address!

Other Programs of Interest
If you want to mirror linux or unix files or directories to a remote server you should consider rsync, http://rsync.samba.org. BackupPC now uses rsync as a transport mechanism; if you are already an rsync user you can think of BackupPC as adding efficient storage (compression and pooling) and a convenient user interface to rsync.

Unison is a utility that can do two-way, interactive, synchronization. See http://www.cis.upenn.edu/~bcpierce/unison.

Three popular open source packages that do tape backup are Amanda (http://www.amanda.org), afbackup (http://sourceforge.net/projects/afbackup), and Bacula (http://www.bacula.org). Amanda can also backup WinXX machines to tape using samba. These packages can be used as back ends to BackupPC to backup the BackupPC server data to tape.

Various programs and scripts use rsync to provide hardlinked backups. See, for example, Mike Rubel's site (http://www.mikerubel.org), J. W. Schultz's dirvish (http://www.pegasys.ws/dirvish), and John Bowman's rlbackup (http://www.math.ualberta.ca/imaging/rlbackup). BackupPC provides many additional features, such as compressed storage, hardlinking any matching files (rather than just files with the same name), and storing special files without root privileges. But these other scripts provide simple and effective solutions and are worthy of consideration.

Road map

Here are some ideas for new features that might appear in future releases of BackupPC:

Comments and suggestions are welcome.

You can help

BackupPC is free. I work on BackupPC because I enjoy doing it and I like to contribute to the open source community.

BackupPC already has more than enough features for my own needs. The main compensation for continuing to work on BackupPC is knowing that more and more people find it useful. So feedback is certainly appreciated. Even negative feedback is helpful, for example ``We evaluated BackupPC but didn't use it because it doesn't ...''.

Beyond being a satisfied user and telling other people about it, everyone is encouraged to add links to http://backuppc.sourceforge.net (I'll see then via Google) or otherwise publicize BackupPC. Unlike the commercial products in this space, I have a zero budget (in both time and money) for marketing, PR and advertising, so it's up to all of you!

Also, everyone is encouraged to contribute patches, bug reports, feature and design suggestions, code, and documentation corrections or improvements.

Back to Top


Installing BackupPC

Requirements

BackupPC requires:

How much disk space do I need?

Here's one real example for an environment that is backing up 65 laptops with compression off. Each full backup averages 3.2GB. Each incremental backup averages about 0.2GB. Storing one full backup and two incremental backups per laptop is around 240GB of raw data. But because of the pooling of identical files, only 87GB is used. This is without compression.

Another example, with compression on: backing up 95 laptops, where each backup averages 3.6GB and each incremental averages about 0.3GB. Keeping three weekly full backups, and six incrementals is around 1200GB of raw data. Because of pooling and compression, only 150GB is needed.

Here's a rule of thumb. Add up the C drive usage of all the machines you want to backup (210GB in the first example above). This is a rough minimum space estimate that should allow a couple of full backups and at least half a dozen incremental backups per machine. If compression is on you can reduce the storage requirements by maybe 30-40%. Add some margin in case you add more machines or decide to keep more old backups.

Your actual mileage will depend upon the types of clients, operating systems and applications you have. The more uniform the clients and applications the bigger the benefit from pooling common files.

For example, the Eudora email tool stores each mail folder in a separate file, and attachments are extracted as separate files. So in the sadly common case of a large attachment emailed to many recipients, Eudora will extract the attachment into a new file. When these machines are backed up, only one copy of the file will be stored on the server, even though the file appears in many different full or incremental backups. In this sense Eudora is a ``friendly'' application from the point of view of backup storage requirements.

An example at the other end of the spectrum is Outlook. Everything (email bodies, attachments, calendar, contact lists) is stored in a single file, which often becomes huge. Any change to this file requires a separate copy of the file to be saved during backup. Outlook is even more troublesome, since it keeps this file locked all the time, so it cannot be read by smbclient whenever Outlook is running. See the Limitations section for more discussion of this problem.

Step 1: Getting BackupPC

Download the latest version from http://backuppc.sourceforge.net.

Step 2: Installing the distribution

First off, there are three perl modules you should install. These are all optional, but highly recommended:

Compress::Zlib
To enable compression, you will need to install Compress::Zlib from http://www.cpan.org. You can run ``perldoc Compress::Zlib'' to see if this module is installed.

Archive::Zip
To support restore via Zip archives you will need to install Archive::Zip, also from http://www.cpan.org. You can run ``perldoc Archive::Zip'' to see if this module is installed.

File::RsyncP
To use rsync and rsyncd with BackupPC you will need to install File::RsyncP. You can run ``perldoc File::RsyncP'' to see if this module is installed. File::RsyncP is available from http://perlrsync.sourceforge.net. Version 0.44 or later is required.

To build and install these packages, fetch the tar.gz file and then run these commands:

    tar zxvf Archive-Zip-1.01.tar.gz
    cd Archive-Zip-1.01
    perl Makefile.PL
    make
    make test
    make install

The same sequence of commands can be used for each module.

Now let's move onto BackupPC itself. After fetching BackupPC-2.0.2.tar.gz, run these commands as root:

    tar zxf BackupPC-2.0.2.tar.gz
    cd BackupPC-2.0.2
    perl configure.pl

You will be prompted for the full paths of various executables, and you will be prompted for the following information:

BackupPC User
It is best if BackupPC runs as a special user, eg backuppc, that has limited privileges. It is preferred that backuppc belongs to a system administrator group so that sys admin members can browse backuppc files, edit the configuration files and so on. Although configurable, the default settings leave group read permission on pool files, so make sure the BackupPC user's group is chosen restrictively.

On this installation, this is backuppc.

Data Directory
You need to decide where to put the data directory, below which all the BackupPC data is stored. This needs to be a big file system.

On this installation, this is /var/lib/backuppc.

Install Directory
You should decide where the BackupPC scripts, libraries and documentation should be installed, eg: /opt/local/BackupPC.

On this installation, this is /usr/share/backuppc.

CGI bin Directory
You should decide where the BackupPC CGI script resides. This will usually below Apache's cgi-bin directory.

On this installation, this is /usr/share/backuppc/cgi-bin.

Apache image directory
A directory where BackupPC's images are stored so that Apache can serve them. This should be somewhere under Apache's DocumentRoot directory.

Step 3: Setting up config.pl

After running configure.pl, browse through the config file, /usr/share/backuppc/conf/config.pl, and make sure all the default settings are correct. In particular, you will need to decide whether to use smb or tar transport (or whether to set it on a per-PC basis), set the smb share password (if using smb), set the backup policies and modify the email message headers and bodies.

BackupPC needs to know the smb share user name and password for each PC that uses smb (ie: all the WinXX clients). The user name is specified in $Conf{SmbShareUserName}. There are four ways to tell BackupPC the smb share password:

Placement and protection of the smb share password is a possible security risk, so please double-check the file and directory permissions. In a future version there might be support for encryption of this password, but a private key will still have to be stored in a protected place. Suggestions are welcome.

Step 4: Setting up the hosts file

The file /var/lib/backuppc/conf/hosts contains the list of clients to backup. BackupPC reads this file in three cases:

Whenever you change the hosts file (to add or remove a host) you can either do a kill -HUP BackupPC_pid or simply wait until the next regular wakeup period.

Each line in the hosts file contains three fields, separated by white space:

Host name
This is typically the host name or NetBios name of the client machine and should be in lower case. The host name can contain spaces (escape with a backslash), but it is not recommended.

Please read the section How BackupPC Finds Hosts.

In certain cases you might want several distinct clients to refer to the same physical machine. For example, you might have a database you want to backup, and you want to bracket the backup of the database with shutdown/restart using $Conf{DumpPreUserCmd} and $Conf{DumpPostUserCmd}. But you also want to backup the rest of the machine while the database is still running. In the case you can specify two different clients in the host file, using any mnemonic name (eg: myhost_mysql and myhost), and use $Conf{ClientNameAlias} in myhost_mysql's config.pl to specify the real host name of the machine.

DHCP flag
Starting with v2.0.0 the way hosts are discovered has changed and now in most cases you should specify 0 for the DHCP flag, even if the host has a dynamically assigned IP address. Please read the section How BackupPC Finds Hosts to understand whether you need to set the DHCP flag.

You only need to set DHCP to 1 if your client machine doesn't respond to the NetBios multicast request:

    nmblookup myHost

but does respond to a request directed to its IP address:

    nmblookup -A W.X.Y.Z

If you do set DHCP to 1 on any client you will need to specify the range of DHCP addresses to search is specified in $Conf{DHCPAddressRanges}.

Note also that the $Conf{ClientNameAlias} feature does not work for clients with DHCP set to 1.


=item User name

This should be the unix login/email name of the user who ``owns'' or uses this machine. This is the user who will be sent email about this machine, and this user will have permission to stop/start/browse/restore backups for this host. Leave this blank if no specific person should receive email or be allowed to stop/start/browse/restore backups for this host. Administrators will still have full permissions.

More users
Additional user names, separate by commas and with no white space, can be specified. These users will also have full permission in the CGI interface to stop/start/browse/restore backups for this host. These users will not be sent email about this host.

The first non-comment line of the hosts file is special: it contains the names of the columns and should not be edited.

Here's a simple example of a hosts file:

    host        dhcp    user      moreUsers
    farside     0       craig     jim,dave
    larson      1       gary      andy

Step 5: Client Setup

Two methods for getting backup data from a client are supported: smb and tar. Smb is the preferred method for WinXX clients and tar is preferred method for linux/unix clients.

The transfer method is set using the $Conf{XferMethod} configuration setting. If you have a mixed environment (ie: you will use smb for some clients and tar for others), you will need to pick the most common choice for $Conf{XferMethod} for the main config.pl file, and then override it in the per-PC config file for those hosts that will use the other method. (Or you could run two completely separate instances of BackupPC, with different data directories, one for WinXX and the other for linux/unix, but then common files between the different machine types will duplicated.)

Here are some brief client setup notes:

WinXX
The preferred setup for WinXX clients is to set $Conf{XferMethod} to ``smb''. (Actually, for v2.0.0, rsyncd is the better method for WinXX if you are prepared to run rsync/cygwin on your WinXX client. More information about this will be provided via the FAQ.)

If you want to use rsyncd for WinXX clients you can find a pre-packaged zip file on http://backuppc.sourceforge.net. The package is called cygwin-rsync. It contains rsync.exe, template setup files and the minimal set of cygwin libraries for everything to run. The README file contains instructions for running rsync as a service, so it starts automatically everytime you boot your machine.

Otherwise, to use SMB, you need to create shares for the data you want to backup. Open ``My Computer'', right click on the drive (eg: C), and select ``Sharing...'' (or select ``Properties'' and select the ``Sharing'' tab). In this dialog box you can enable sharing, select the share name and permissions. Many machines will be configured by default to share the entire C drive as C$ using the administrator password.

If this machine uses DHCP you will also need to make sure the NetBios name is set. Go to Control Panel|System|Network Identification (on Win2K) or Control Panel|System|Computer Name (on WinXP). Also, you should go to Control Panel|Network Connections|Local Area Connection|Properties|Internet Protocol (TCP/IP)|Properties|Advanced|WINS and verify that NetBios is not disabled.

As an alternative to setting $Conf{XferMethod} to ``smb'' (using smbclient) for WinXX clients, you can use an smb network filesystem (eg: ksmbfs or similar) on your linux/unix server to mount the share, and then set $Conf{XferMethod} to ``tar'' (use tar on the network mounted file system).

Also, to make sure that file names with 8-bit characters are correctly transferred by smbclient you should add this to samba's smb.conf file:

    [global]
        # Accept the windows charset
        client code page = 850
        character set = ISO8859-1

This setting should work for western europe. See http://www.oreilly.com/catalog/samba/chapter/book/ch08_03.html for more information about settings for other languages.

Linux/Unix
The preferred setup for linux/unix clients is to set $Conf{XferMethod} to ``rsync'', ``rsyncd'' or ``tar''.

You can use either rsync, smb, or tar for linux/unix machines. Smb requires that the Samba server (smbd) be run to provide the shares. Since the smb protocol can't represent special files like symbolic links and fifos, tar and rsync are the better transport methods for linux/unix machines. (In fact, by default samba makes symbolic links look like the file or directory that they point to, so you could get an infinite loop if a symbolic link points to the current or parent directory. If you really need to use Samba shares for linux/unix backups you should turn off the ``follow symlinks'' samba config setting. See the smb.conf manual page.)

The requirements for each Xfer Method are:

tar
You must have GNU tar on the client machine. Use ``tar --version'' or ``gtar --version'' to verify. The version should be at least 1.13.7, and 1.13.20 or greater is recommended. Tar is run on the client machine via rsh or ssh.

The relevant configuration settings are $Conf{TarClientPath}, $Conf{TarShareName}, $Conf{TarClientCmd}, $Conf{TarFullArgs}, $Conf{TarIncrArgs}, and $Conf{TarClientRestoreCmd}.

rsync
You should have at least rsync 2.5.5, and the latest version 2.5.6 is recommended. Rsync is run on the remote client via rsh or ssh.

The relevant configuration settings are $Conf{RsyncClientPath}, $Conf{RsyncClientCmd}, $Conf{RsyncClientRestoreCmd}, $Conf{RsyncShareName}, $Conf{RsyncArgs}, $Conf{RsyncRestoreArgs} and $Conf{RsyncLogLevel}.

rsyncd
You should have at least rsync 2.5.5, and the latest version 2.5.6 is recommended. In this case the rsync daemon should be running on the client machine and BackupPC connects directly to it.

The relevant configuration settings are $Conf{RsyncdClientPort}, $Conf{RsyncdUserName}, $Conf{RsyncdPasswd}, $Conf{RsyncdAuthRequired}, $Conf{RsyncShareName}, $Conf{RsyncArgs}, $Conf{RsyncRestoreArgs} and $Conf{RsyncLogLevel}. In the case of rsyncd, $Conf{RsyncShareName} is the name of an rsync module (ie: the thing in square brackets in rsyncd's conf file -- see rsyncd.conf), not a file system path.

For linux/unix machines you should not backup ``/proc''. This directory contains a variety of files that look like regular files but they are special files that don't need to be backed up (eg: /proc/kcore is a regular file that contains physical memory). See $Conf{BackupFilesExclude}. It is safe to back up /dev since it contains mostly character-special and block-special files, which are correctly handed by BackupPC (eg: backing up /dev/hda5 just saves the block-special file information, not the contents of the disk).

Alternatively, rather than backup all the file systems as a single share (``/''), it is easier to restore a single file system if you backup each file system separately. To do this you should list each file system mount point in $Conf{TarShareName} or $Conf{RsyncShareName}, and add the --one-file-system option to $Conf{TarClientCmd} or add --one-file-system (note the different punctuation) to $Conf{RsyncArgs}. In this case there is no need to exclude /proc explicitly since it looks like a different file system.

Next you should decide whether to run tar over ssh, rsh or nfs. Ssh is the preferred method. Rsh is not secure and therefore not recommended. Nfs will work, but you need to make sure that the BackupPC user (running on the server) has sufficient permissions to read all the files below the nfs mount.

Ssh allows BackupPC to run as a privileged user on the client (eg: root), since it needs sufficient permissions to read all the backup files. Ssh is setup so that BackupPC on the server (an otherwise low privileged user) can ssh as root on the client, without being prompted for a password. There are two common versions of ssh: v1 and v2. Here are some instructions for one way to setup ssh. (Check which version of SSH you have by typing ``ssh'' or ``man ssh''.)

OpenSSH Instructions
Depending upon your OpenSSH installation, many of these steps can be replaced by running the scripts ssh-user-config and ssh-host-config included with OpenSSH. You still need to manually exchange the keys.
Key generation
As root on the client machine, use ssh-keygen to generate a public/private key pair, without a pass-phrase:
    ssh-keygen -t rsa -N ''

This will save the public key in ~/.ssh/id_rsa.pub and the private key in ~/.ssh/id_rsa.

BackupPC setup
Repeat the above steps for the BackupPC user (backuppc) on the server. Make a copy of the public key to make it recognizable, eg:
    ssh-keygen -t rsa -N ''
    cp ~/.ssh/id_rsa.pub ~/.ssh/BackupPC_id_rsa.pub

See the ssh and sshd manual pages for extra configuration information.

Key exchange
To allow BackupPC to ssh to the client as root, you need to place BackupPC's public key into root's authorized list on the client. Append BackupPC's public key (BackupPC_id_rsa.pub) to root's ~/.ssh/authorized_keys2 file on the client:
    touch ~/.ssh/authorized_keys2
    cat BackupPC_id_rsa.pub >> ~/.ssh/authorized_keys2

You should edit ~/.ssh/authorized_keys2 and add further specifiers, eg: from, to limit which hosts can login using this key. For example, if your BackupPC host is called backuppc.my.com, there should be one line in ~/.ssh/authorized_keys2 that looks like:

    from="backuppc.my.com" ssh-rsa [base64 key, eg: ABwBCEAIIALyoqa8....]

Fix permissions
You will probably need to make sure that all the files in ~/.ssh have no group or other read/write permission:
    chmod -R go-rwx ~/.ssh

You should do the same thing for the BackupPC user on the server.

Testing
As the BackupPC user on the server, verify that this command:
    ssh -l root clientHostName whoami

prints

    root

You might be prompted the first time to accept the client's host key and you might be prompted for root's password on the client. Make sure that this command runs cleanly with no prompts after the first time. You might need to check /etc/hosts.equiv on the client. Look at the man pages for more information. The ``-v'' option to ssh is a good way to get detailed information about what fails.

SSH2 Instructions
Key generation
As root on the client machine, use ssh-keygen2 to generate a public/private key pair, without a pass-phrase:
    ssh-keygen2 -t rsa -P

or:

    ssh-keygen -t rsa -N ''

(This command might just be called ssh-keygen on your machine.)

This will save the public key in /.ssh2/id_rsa_1024_a.pub and the private key in /.ssh2/id_rsa_1024_a.

Identification
Create the identification file /.ssh2/identification:
    echo "IdKey id_rsa_1024_a" > /.ssh2/identification

BackupPC setup
Repeat the above steps for the BackupPC user (backuppc) on the server. Rename the key files to recognizable names, eg:
    ssh-keygen2 -t rsa -P
    mv ~/.ssh2/id_rsa_1024_a.pub ~/.ssh2/BackupPC_id_rsa_1024_a.pub
    mv ~/.ssh2/id_rsa_1024_a     ~/.ssh2/BackupPC_id_rsa_1024_a
    echo "IdKey BackupPC_id_rsa_1024_a" > ~/.ssh2/identification

Based on your ssh2 configuration, you might also need to turn off StrictHostKeyChecking and PasswordAuthentication:

    touch ~/.ssh2/ssh2_config
    echo "StrictHostKeyChecking ask" >> ~/.ssh2/ssh2_config
    echo "PasswordAuthentication no" >> ~/.ssh2/ssh2_config

Key exchange
To allow BackupPC to ssh to the client as root, you need to place BackupPC's public key into root's authorized list on the client. Copy BackupPC's public key (BackupPC_id_rsa_1024_a.pub) to the /.ssh2 directory on the client. Add the following line to the /.ssh2/authorization file on the client (as root):
    touch /.ssh2/authorization
    echo "Key BackupPC_id_rsa_1024_a.pub" >> /.ssh2/authorization

Fix permissions
You will probably need to make sure that all the files in /.ssh2 have no group or other read/write permission:
    chmod -R go-rwx /.ssh2

You should do the same thing for the BackupPC user on the server.

Testing
As the BackupPC user on the server, verify that this command:
    ssh2 -l root clientHostName whoami

prints

    root

You might be prompted the first time to accept the client's host key and you might be prompted for root's password on the client. Make sure that this command runs cleanly with no prompts after the first time. You might need to check /etc/hosts.equiv on the client. Look at the man pages for more information. The ``-v'' option to ssh2 is a good way to get detailed information about what fails.

SSH version 1 Instructions
The concept is identical and the steps are similar, but the specific commands and file names are slightly different.

First, run ssh-keygen on the client (as root) and server (as the BackupPC user) and simply hit enter when prompted for the pass-phrase:

    ssh-keygen

This will save the public key in /.ssh/identity.pub and the private key in /.ssh/identity.

Next, append BackupPC's ~/.ssh/identity.pub (from the server) to root's /.ssh/authorized_keys file on the client. It's a single long line that you can cut-and-paste with an editor (make sure it remains a single line).

Next, force protocol version 1 by adding:

    Protocol 1

to BackupPC's ~/.ssh/config on the server.

Next, run ``chmod -R go-rwx ~/.ssh'' on the server and ``chmod -R go-rwx /.ssh'' on the client.

Finally, test using:

    ssh -l root clientHostName whoami

Finally, if this machine uses DHCP you will need to run nmbd (the NetBios name server) from the Samba distribution so that the machine responds to a NetBios name request. See the manual page and Samba documentation for more information.

Step 6: Running BackupPC

The installation contains an init.d backuppc script that can be copied to /etc/init.d so that BackupPC can auto-start on boot. See init.d/README for further instructions.

BackupPC should be ready to start. If you installed the init.d script, then you should be able to run BackupPC with:

    /etc/init.d/backuppc start

(This script can also be invoked with ``stop'' to stop BackupPC and ``reload'' to tell BackupPC to reload config.pl and the hosts file.)

Otherwise, just run

     /usr/share/backuppc/bin/BackupPC -d

as user backuppc. The -d option tells BackupPC to run as a daemon (ie: it does an additional fork).

Any immediate errors will be printed to stderr and BackupPC will quit. Otherwise, look in /var/lib/backuppc/log/LOG and verify that BackupPC reports it has started and all is ok.

Step 7: Talking to BackupPC

Note: as of version 1.5.0, BackupPC no longer supports telnet to its TCP port. First off, a unix domain socket is used instead of a TCP port. (The TCP port can still be re-enabled if your installation has apache and BackupPC running on different machines.) Secondly, even if you still use the TCP port, the messages exchanged over this interface are now protected by an MD5 digest based on a shared secret (see $Conf{ServerMesgSecret}) as well as sequence numbers and per-session unique keys, preventing forgery and replay attacks.

You should verify that BackupPC is running by using BackupPC_serverMesg. This sends a message to BackupPC via the unix (or TCP) socket and prints the response.

You can request status information and start and stop backups using this interface. This socket interface is mainly provided for the CGI interface (and some of the BackupPC sub-programs use it too). But right now we just want to make sure BackupPC is happy. Each of these commands should produce some status output:

    /usr/share/backuppc/bin/BackupPC_serverMesg status info
    /usr/share/backuppc/bin/BackupPC_serverMesg status jobs
    /usr/share/backuppc/bin/BackupPC_serverMesg status hosts

The output should be some hashes printed with Data::Dumper. If it looks cryptic and confusing, and doesn't look like an error message, then all is ok.

The jobs status should initially show just BackupPC_trashClean. The hosts status should produce a list of every host you have listed in /var/lib/backuppc/conf/hosts as part of a big cryptic output line.

You can also request that all hosts be queued:

    /usr/share/backuppc/bin/BackupPC_serverMesg backup all

At this point you should make sure the CGI interface works since it will be much easier to see what is going on. That's our next subject.

Step 8: CGI interface

The CGI interface script, BackupPC_Admin, is a powerful and flexible way to see and control what BackupPC is doing. It is written for an Apache server. If you don't have Apache, see http://www.apache.org.

There are two options for setting up the CGI interface: standard mode and using mod_perl. Mod_perl provides much higher performance (around 15x) and is the best choice if your Apache was built with mod_perl support. To see if your apache was built with mod_perl run this command:

    httpd -l | egrep mod_perl

If this prints mod_perl.c then your Apache supports mod_perl.

Using mod_perl with BackupPC_Admin requires a dedicated Apache to be run as the BackupPC user (backuppc). This is because BackupPC_Admin needs permission to access various files in BackupPC's data directories. In contrast, the standard installation (without mod_perl) solves this problem by having BackupPC_Admin installed as setuid to the BackupPC user, so that BackupPC_Admin runs as the BackuPC user.

Here are some specifics for each setup:

Standard Setup
The CGI interface should have been installed by the configure.pl script in /usr/share/backuppc/cgi-bin/BackupPC_Admin. BackupPC_Admin should have been installed as setuid to the BackupPC user (backuppc), in addition to user and group execute permission.

You should be very careful about permissions on BackupPC_Admin and the directory /usr/share/backuppc/cgi-bin: it is important that normal users cannot directly execute or change BackupPC_Admin, otherwise they can access backup files for any PC. You might need to change the group ownership of BackupPC_Admin to a group that Apache belongs to so that Apache can execute it (don't add ``other'' execute permission!). The permissions should look like this:

    ls -l /usr/share/backuppc/cgi-bin/BackupPC_Admin
    -swxr-x---    1 backuppc   web      82406 Jun 17 22:58 /usr/share/backuppc/cgi-bin/BackupPC_Admin

The setuid script won't work unless perl on your machine was installed with setuid emulation. This is likely the problem if you get an error saying such as ``Wrong user: my userid is 25, instead of 150'', meaning the script is running as the httpd user, not the BackupPC user. This is because setuid scripts are disabled by the kernel in most flavors of unix and linux.

To see if your perl has setuid emulation, see if there is a program called sperl5.6.0 or sperl5.6.1 in the place where perl is installed. If you can't find this program, then you have two options: rebuild and reinstall perl with the setuid emulation turned on (answer ``y'' to the question ``Do you want to do setuid/setgid emulation?'' when you run perl's configure script), or switch to the mod_perl alternative for the CGI script (which doesn't need setuid to work).

Mod_perl Setup
The advantage of the mod_perl setup is that no setuid script is needed, and there is a huge performance advantage. Not only does all the perl code need to be parsed just once, the config.pl and hosts files, plus the connection to the BackupPC server are cached between requests. The typical speedup is around 15 times.

To use mod_perl you need to run Apache as user backuppc. If you need to run multiple Apache's for different services then you need to create multiple top-level Apache directories, each with their own config file. You can make copies of /etc/init.d/httpd and use the -d option to httpd to point each http to a different top-level directory. Or you can use the -f option to explicitly point to the config file. Multiple Apache's will run on different Ports (eg: 80 is standard, 8080 is a typical alternative port accessed via http://yourhost.com:8080).

Inside BackupPC's Apache http.conf file you should check the settings for ServerRoot, DocumentRoot, User, Group, and Port. See http://httpd.apache.org/docs/server-wide.html for more details.

For mod_perl, BackupPC_Admin should not have setuid permission, so you should turn it off:

    chmod u-s /usr/share/backuppc/cgi-bin/BackupPC_Admin

To tell Apache to use mod_perl to execute BackupPC_Admin, add this to Apache's 1.x httpd.conf file:

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

Apache 2.0.44 with Perl 5.8.0 on RedHat 7.1, Don Silvia reports that this works:

    LoadModule perl_module modules/mod_perl.so
    PerlModule Apache2
    <Location /path/to/cgi/>
        SetHandler perl-script
        PerlResponseHandler ModPerl::Registry
        PerlOptions +ParseHeaders
        Options +ExecCGI
        Order deny,allow
        Deny from all
        Allow from 192.168.0  
        AuthName "Backup Admin"
        AuthType Basic
        AuthUserFile /path/to/user_file
        Require valid-user
    </Location>

There are other optimizations and options with mod_perl. For example, you can tell mod_perl to preload various perl modules, which saves memory compared to loading separate copies in every Apache process after they are forked. See Stas's definitive mod_perl guide at http://perl.apache.org/guide.

BackupPC_Admin requires that users are authenticated by Apache. Specifically, it expects that Apache sets the REMOTE_USER environment variable when it runs. There are several ways to do this. One way is to create a .htaccess file in the cgi-bin directory that looks like:

    AuthGroupFile /etc/httpd/conf/group    # <--- change path as needed
    AuthUserFile /etc/http/conf/passwd     # <--- change path as needed
    AuthType basic
    AuthName "access"
    require valid-user

You will also need ``AllowOverride Indexes AuthConfig'' in the Apache httpd.conf file to enable the .htaccess file. Alternatively, everything can go in the Apache httpd.conf file inside a Location directive. The list of users and password file above can be extracted from the NIS passwd file.

One alternative is to use LDAP. In Apache's http.conf add these lines:

    LoadModule auth_ldap_module   modules/auth_ldap.so
    AddModule auth_ldap.c
    # cgi-bin - auth via LDAP (for BackupPC)
    <Location /cgi-binBackupPC/BackupPC_Admin>    # <--- change path as needed
      AuthType Basic
      AuthName "BackupPC login"
      # replace MYDOMAIN, PORT, ORG and CO as needed
      AuthLDAPURL ldap://ldap.MYDOMAIN.com:PORT/o=ORG,c=CO?uid?sub?(objectClass=*)
      require valid-user
    </Location>

If you want to disable the user authentication you can set $Conf{CgiAdminUsers} to '*', which allows any user to have full access to all hosts and backups. In this case the REMOTE_USER environment variable does not have to be set by Apache.

Alternatively, you can force a particular user name by getting Apache to set REMOTE_USER, eg, to hardcode the user to www you could add this to Apache's httpd.conf:

    <Location /cgi-bin/BackupPC/BackupPC_Admin>   # <--- change path as needed
        Setenv REMOTE_USER www
    </Location>

Finally, you should also edit the config.pl file and adjust, as necessary, the CGI-specific settings. They're near the end of the config file. In particular, you should specify which users or groups have administrator (privileged) access: see the config settings $Conf{CgiAdminUserGroup} and $Conf{CgiAdminUsers}. Also, the configure.pl script placed various images into $Conf{CgiImageDir} that BackupPC_Admin needs to serve up. You should make sure that $Conf{CgiImageDirURL} is the correct URL for the image directory.

See the section Debugging installation problems for suggestions on debugging the Apache authentication setup.

How BackupPC Finds Hosts

Starting with v2.0.0 the way hosts are discovered has changed. In most cases you should specify 0 for the DHCP flag in the conf/hosts file, even if the host has a dynamically assigned IP address.

BackupPC (starting with v2.0.0) looks up hosts with DHCP = 0 in this manner:

For hosts that have the DHCP flag set to 1, these machines are discovered as follows:

Other installation topics

Removing a client
If there is a machine that no longer needs to be backed up (eg: a retired machine) you have two choices. First, you can keep the backups accessible and browsable, but disable all new backups. Alternatively, you can completely remove the client and all its backups.

To disable backups for a client there are two special values for $Conf{FullPeriod} in that client's per-PC config.pl file:

-1
Don't do any regular backups on this machine. Manually requested backups (via the CGI interface) will still occur.

-2
Don't do any backups on this machine. Manually requested backups (via the CGI interface) will be ignored.

This will still allow that client's old backups to be browsable and restorable.

To completely remove a client and all its backups, you should remove its entry in the conf/hosts file, and then delete the /var/lib/backuppc/pc/$host directory. Whenever you change the hosts file, you should send BackupPC a HUP (-1) signal so that it re-reads the hosts file. If you don't do this, BackupPC will automatically re-read the hosts file at the next regular wakeup.

Note that when you remove a client's backups you won't initially recover a lot of disk space. That's because the client's files are still in the pool. Overnight, when BackupPC_nightly next runs, all the unused pool files will be deleted and this will recover the disk space used by the client's backups.

Copying the pool
If the pool disk requirements grow you might need to copy the entire data directory to a new (bigger) file system. Hopefully you are lucky enough to avoid this by having the data directory on a RAID file system or LVM that allows the capacity to be grown in place by adding disks.

The backup data directories contain large numbers of hardlinks. If you try to copy the pool the target directory will occupy a lot more space if the hardlinks aren't re-established.

The GNU cp program with the -a option is aware of hardlinks and knows to re-establish them. So GNU cp -a is the recommended way to copy the data directory and pool. Don't forget to stop BackupPC while the copy runs.

Compressing an existing pool
If you are upgrading BackupPC and want to turn compression on you have two choices:

The rest of this section discusses how to run BackupPC_compressPool.

BackupPC_compressPool takes three command line options:

-t
Test mode: do everything except actually replace the pool files. Useful for estimating total run time without making any real changes.

-r
Read check: re-read the compressed file and compare it against the original uncompressed file. Can only be used in test mode.

-c #
Number of children to fork. BackupPC_compressPool can take a long time to run, so to speed things up it spawns four children, each working on a different part of the pool. You can change the number of children with the -c option.

Here are the recommended steps for running BackupPC_compressPool:

After BackupPC_compressPool completes you should have a complete set of compressed backups (and your disk usage should be lower). You can now re-start BackupPC.

Debugging installation problems

This section will probably grow based on the types of questions on the BackupPC mail list. Eventually the FAQ at http://backuppc.sourceforge.net/faq/ will include more details than this section.

Check log files
Assuming BackupPC can start correctly you should inspect /var/lib/backuppc/log/LOG for any errors. Assuming backups for a particular host start, you should be able to look in /var/lib/backuppc/pc/$host/LOG for error messages specific to that host. Always check both log files.

CGI script doesn't run
Perhaps the most common program with the installation is getting the CGI script to run. Often the setuid isn't configured correctly, or doesn't work on your system.

First, try running BackupPC_Admin manually as the BackupPC user, eg:

    su backuppc
    /usr/share/backuppc/cgi-bin/BackupPC_Admin

Now try running it as the httpd user (which ever user apache runs as);

    su httpd
    /usr/share/backuppc/cgi-bin/BackupPC_Admin

In both cases do you get normal html output?

If the first case works but the second case fails with an error that the wrong user is running the script then you have a setuid problem. (This assumes you are running BackupPC_Admin without mod_perl, and you therefore need seduid to work. If you are using mod_perl then apache should run as user backuppc.)

First you should make sure the cgi-bin directory is on a file system that doesn't have the ``nosuid'' mount option.

Next, experiment by creating this script:

    #!/bin/perl
    printf("My userid is $> (%s)\n", (getpwuid($>))[0]);

then chown it to backuppc and chmod u+s:

    root# chown backuppc testsetuid
    root# chmod u+s testsetuid
    root# chmod a+x testsetuid
    root# ls -l testsetuid
    -rwsr-xr-x    1 backuppc  wheel          76 Aug 26 09:46 testsetuid*

Now run this program as a normal user. What uid does it print? Try changing the first line of the script to directly call sperl:

    #!/usr/bin/sperl5.8.0

(modify according to your version and path). Does this work instead?

Finally, you should invoke the CGI script from a browser, using a URL like:

    http://myHost/cgi-bin/BackupPC/BackupPC_Admin

You should make sure REMOTE_USER is being set by apache (see the earlier section) so that user authentication works. Make sure the config settings $Conf{CgiAdminUserGroup} and $Conf{CgiAdminUsers} correctly specify the privileged administrator users.

You cannot access per-host information in the CGI interface
If you get the error
    Only privileged users can view information about host xyz

it means that BackupPC_Admin is unable to match the user's login name (supplied by Apache via the REMOTE_USER environment variable) with either that host's user name (in the conf/hosts file) or with the administrators specified in the $Conf{CgiAdminUsers} or $Conf{CgiAdminUserGroup} settings.

The most common problem is that REMOTE_USER is not set because the Apache authentication is not correctly configured. In this case BackupPC_Admin will report this additional error:

    Note: $ENV{REMOTE_USER} is not set, which could mean there is an
    installation problem.  BackupPC_Admin expects Apache to authenticate
    the user and pass their user name into this script as the REMOTE_USER
    environment variable.  See the documentation.

You should review the configuration instructions to setup Apache authentication correctly. To test if REMOTE_USER is being set correctly, there is a simple script called printenv that is included with Apache. This is a simple CGI script that prints out all the environment variables. Place this script in the same directory as BackupPC_Admin and run it with a URL like:

    http://myHost/cgi-bin/BackupPC/printenv

Check the value of the REMOTE_USER environment variable. Here's a copy of the printenv script:

    #!/usr/bin/perl
    ##
    ##  printenv -- demo CGI program which just prints its environment
    ##
    print "Content-type: text/plain\n\n";
    foreach $var (sort(keys(%ENV))) {
        $val = $ENV{$var};
        $val =~ s|\n|\\n|g;
        $val =~ s|"|\\"|g;
        print "${var}=\"${val}\"\n";
    }

Can't ping or find host
Please read the section How BackupPC Finds Hosts.

The BackupPC_dump command now has a -v option, so the easiest way to debug backup problems on a specific host is to run BackupPC_dump manually as the BackupPC user:

    su backuppc
    /usr/share/backuppc/bin/BackupPC_dump -v -f hostName

This will run a full dump on hostName (replace with your host name). It will show each command (eg: ping, nmblookup and the full dump commands) and the output from each command. Reading the output carefully should show you what the problem is.

You can also verify that nmblookup correctly returns the netbios name. This is essential for DHCP hosts, and depending upon the setting of $Conf{FixedIPNetBiosNameCheck} might also be required for fixed IP address hosts too. Run this command:

    nmblookup -A hostName

Verify that the host name is printed. The output might look like:

    received 7 names
            DELLLS13        <00> -         P <ACTIVE> 
            DOMAINNAME      <00> - <GROUP> P <ACTIVE> 
            DELLLS13        <20> -         P <ACTIVE> 
            DOMAINNAME      <1e> - <GROUP> P <ACTIVE> 
            DELLLS13        <03> -         P <ACTIVE> 
            DELLLS13$       <03> -         P <ACTIVE> 
            CRAIG           <03> -         P <ACTIVE>

The first name, converted to lower case, is used for the host name.

Transport method doesn't work
The BackupPC_dump command has a -v option, so the easiest way to debug backup problems on a specific host is to run BackupPC_dump manually as the BackupPC user:
    su backuppc
    /usr/share/backuppc/bin/BackupPC_dump -v -f hostName

This will run a full dump on hostName (replace with your host name) and will print all the output from each command, including the log output.

The most likely problems will relate to connecting to the smb shares on each host. On each failed backup, a file /var/lib/backuppc/pc/$host/XferLOG.bad.z will be created. This is the stderr output from the transport program. You can view this file via the CGI interface, or manually uncompress it with;

    /usr/share/backuppc/bin/BackupPC_zcat /var/lib/backuppc/pc/$host/XferLOG.bad.z | more

The first line will show the full command that was run (eg: rsync, tar or smbclient). Based on the error messages you should figure out what is wrong. Possible errors on the server side are invalid host, invalid share name, bad username or password. Possible errors on the client side are misconfiguration of the share, username or password.

You should try running the command manually to see what happens. For example, for smbclient you should it manually and verify that you can connect to the host in interactive mode, eg:

    smbclient '\\hostName\shareName' -U userName

shareName should match the $Conf{SmbShareName} setting and userName should match the the $Conf{SmbShareUserName} setting.

You will be prompted for the password. You should then see this prompt:

    smb: \>

Verify that ``ls'' works and then type ``quit'' to exit.

Back to Top


Restore functions

BackupPC supports several different methods for restoring files. The most convenient restore options are provided via the CGI interface. Alternatively, backup files can be restored using manual commands.

CGI restore options

By selecting a host in the CGI interface, a list of all the backups for that machine will be displayed. By selecting the backup number you can navigate the shares and directory tree for that backup.

BackupPC's CGI interface automatically fills incremental backups with the corresponding full backup, which means each backup has a filled appearance. Therefore, there is no need to do multiple restores from the incremental and full backups: BackupPC does all the hard work for you. You simply select the files and directories you want from the correct backup vintage in one step.

You can download a single backup file at any time simply by selecting it. Your browser should prompt you with the file name and ask you whether to open the file or save it to disk.

Alternatively, you can select one or more files or directories in the currently selected directory and select ``Restore selected files''. (If you need to restore selected files and directories from several different parent directories you will need to do that in multiple steps.)

If you select all the files in a directory, BackupPC will replace the list of files with the parent directory. You will be presented with a screen that has three options:

Option 1: Direct Restore
With this option the selected files and directories are restored directly back onto the host, by default in their original location. Any old files with the same name will be overwritten, so use caution. You can optionally change the target host name, target share name, and target path prefix for the restore, allowing you to restore the files to a different location.

Once you select ``Start Restore'' you will be prompted one last time with a summary of the exact source and target files and directories before you commit. When you give the final go ahead the restore operation will be queued like a normal backup job, meaning that it will be deferred if there is a backup currently running for that host. When the restore job is run, smbclient or tar is used (depending upon $Conf{XferMethod}) to actually restore the files. Sorry, there is currently no option to cancel a restore that has been started.

A record of the restore request, including the result and list of files and directories, is kept. It can be browsed from the host's home page. $Conf{RestoreInfoKeepCnt} specifies how many old restore status files to keep.

Option 2: Download Zip archive
With this option a zip file containing the selected files and directories is downloaded. The zip file can then be unpacked or individual files extracted as necessary on the host machine. The compression level can be specified. A value of 0 turns off compression.

When you select ``Download Zip File'' you should be prompted where to save the restore.zip file.

BackupPC does not consider downloading a zip file as an actual restore operation, so the details are not saved for later browsing as in the first case. However, a mention that a zip file was downloaded by a particular user, and a list of the files, does appear in BackupPC's log file.

Option 3: Download Tar archive
This is identical to the previous option, except a tar file is downloaded rather than a zip file (and there is currently no compression option).

Command-line restore options

Apart from the CGI interface, BackupPC allows you to restore files and directories from the command line. The following programs can be used:

BackupPC_zcat
For each file name argument it inflates (uncompresses) the file and writes it to stdout. To use BackupPC_zcat you could give it the full file name, eg:
    /usr/share/backuppc/bin/BackupPC_zcat /var/lib/backuppc/pc/host/5/fc/fcraig/fexample.txt > example.txt

It's your responsibility to make sure the file is really compressed: BackupPC_zcat doesn't check which backup the requested file is from.

BackupPC_tarCreate
BackupPC_tarCreate creates a tar file for any files or directories in a particular backup. Merging of incrementals is done automatically, so you don't need to worry about whether certain files appear in the incremental or full backup.

The usage is:

   BackupPC_tarCreate [-t] [-h host] [-n dumpNum] [-s shareName]
                    [-r pathRemove] [-p pathAdd]
                    files/directories...

The command-line files and directories are relative to the specified shareName. The tar file is written to stdout.

The required options are:

-h host
host from which the tar archive is created

-n dumpNum
dump number from which the tar archive is created

-s shareName
share name from which the tar archive is created

Other options are:

-t
print summary totals

-r pathRemove
path prefix that will be replaced with pathAdd

-p pathAdd
new path prefix

The -h, -n and -s options specify which dump is used to generate the tar archive. The -r and -p options can be used to relocate the paths in the tar archive so extracted files can be placed in a location different from their original location.

BackupPC_zipCreate
BackupPC_zipCreate creates a zip file for any files or directories in a particular backup. Merging of incrementals is done automatically, so you don't need to worry about whether certain files appear in the incremental or full backup.

The usage is:

   BackupPC_zipCreate [-t] [-h host] [-n dumpNum] [-s shareName]
                    [-r pathRemove] [-p pathAdd] [-c compressionLevel]
                   files/directories...

The command-line files and directories are relative to the specified shareName. The zip file is written to stdout.

The required options are:

-h host
host from which the zip archive is created

-n dumpNum
dump number from which the zip archive is created

-s shareName
share name from which the zip archive is created

Other options are:

-t
print summary totals

-r pathRemove
path prefix that will be replaced with pathAdd

-p pathAdd
new path prefix

-c level
compression level (default is 0, no compression)

The -h, -n and -s options specify which dump is used to generate the zip archive. The -r and -p options can be used to relocate the paths in the zip archive so extracted files can be placed in a location different from their original location.

Each of these programs reside in /usr/share/backuppc/bin.

Back to Top


BackupPC Design

Some design issues

Pooling common files
To quickly see if a file is already in the pool, an MD5 digest of the file length and contents is used as the file name in the pool. This can't guarantee a file is identical: it just reduces the search to often a single file or handful of files. A complete file comparison is always done to verify if two files are really the same.

Identical files on multiples backups are represented by hard links. Hardlinks are used so that identical files all refer to the same physical file on the server's disk. Also, hard links maintain reference counts so that BackupPC knows when to delete unused files from the pool.

For the computer-science majors among you, you can think of the pooling system used by BackupPC as just a chained hash table stored on a (big) file system.

The hashing function
There is a tradeoff between how much of file is used for the MD5 digest and the time taken comparing all the files that have the same hash.

Using the file length and just the first 4096 bytes of the file for the MD5 digest produces some repetitions. One example: with 900,000 unique files in the pool, this hash gives about 7,000 repeated files, and in the worst case 500 files have the same hash. That's not bad: we only have to do a single file compare 99.2% of the time. But in the worst case we have to compare as many as 500 files checking for a match.

With a modest increase in CPU time, if we use the file length and the first 256K of the file we now only have 500 repeated files and in the worst case around 20 files have the same hash. Furthermore, if we instead use the first and last 128K of the file (more specifically, the first and eighth 128K chunks for files larger than 1MB) we get only 300 repeated files and in the worst case around 20 files have the same hash.

Based on this experimentation, this is the hash function used by BackupPC. It is important that you don't change the hash function after files are already in the pool. Otherwise your pool will grow to twice the size until all the old backups (and all the old files with old hashes) eventually expire.

Compression
BackupPC supports compression. It uses the deflate and inflate methods in the Compress::Zlib module, which is based on the zlib compression library (see http://www.gzip.org/zlib/).

The $Conf{CompressLevel} setting specifies the compression level to use. Zero (0) means no compression. Compression levels can be from 1 (least cpu time, slightly worse compression) to 9 (most cpu time, slightly better compression). The recommended value is 3. Changing it to 5, for example, will take maybe 20% more cpu time and will get another 2-3% additional compression. Diminishing returns set in above 5. See the zlib documentation for more information about compression levels.

BackupPC implements compression with minimal CPU load. Rather than compressing every incoming backup file and then trying to match it against the pool, BackupPC computes the MD5 digest based on the uncompressed file, and matches against the candidate pool files by comparing each uncompressed pool file against the incoming backup file. Since inflating a file takes roughly a factor of 10 less CPU time than deflating there is a big saving in CPU time.

The combination of pooling common files and compression can yield a factor of 8 or more overall saving in backup storage.

BackupPC operation

BackupPC reads the configuration information from /var/lib/backuppc/conf/config.pl. It then runs and manages all the backup activity. It maintains queues of pending backup requests, user backup requests and administrative commands. Based on the configuration various requests will be executed simultaneously.

As specified by $Conf{WakeupSchedule}, BackupPC wakes up periodically to queue backups on all the PCs. This is a four step process:

  1. For each host and DHCP address backup requests are queued on the background command queue.

  2. For each PC, BackupPC_dump is forked. Several of these may be run in parallel, based on the configuration. First a ping is done to see if the machine is alive. If this is a DHCP address, nmblookup is run to get the netbios name, which is used as the host name. The file /var/lib/backuppc/pc/$host/backups is read to decide whether a full or incremental backup needs to be run. If no backup is scheduled, or the ping to $host fails, then BackupPC_dump exits.

    The backup is done using samba's smbclient or tar over ssh/rsh/nfs piped into BackupPC_tarExtract, extracting the backup into /var/lib/backuppc/pc/$host/new. The smbclient or tar output is put into /var/lib/backuppc/pc/$host/XferLOG.

    As BackupPC_tarExtract extracts the files from smbclient, it checks each file in the backup to see if it is identical to an existing file from any previous backup of any PC. It does this without needed to write the file to disk. If the file matches an existing file, a hardlink is created to the existing file in the pool. If the file does not match any existing files, the file is written to disk and the file name is saved in /var/lib/backuppc/pc/$host/NewFileList for later processing by BackupPC_link. BackupPC_tarExtract can handle arbitrarily large files and multiple candidate matching files without needing to write the file to disk in the case of a match. This significantly reduces disk writes (and also reads, since the pool file comparison is done disk to memory, rather than disk to disk).

    Based on the configuration settings, BackupPC_dump checks each old backup to see if any should be removed. Any expired backups are moved to /var/lib/backuppc/trash for later removal by BackupPC_trashClean.

  3. For each complete, good, backup, BackupPC_link is run. To avoid race conditions as new files are linked into the pool area, only a single BackupPC_link program runs at a time and the rest are queued.

    BackupPC_link reads the NewFileList written by BackupPC_dump and inspects each new file in the backup. It re-checks if there is a matching file in the pool (another BackupPC_link could have added the file since BackupPC_dump checked). If so, the file is removed and replaced by a hard link to the existing file. If the file is new, a hard link to the file is made in the pool area, so that this file is available for checking against each new file and new backup.

    Then, assuming $Conf{IncrFill} is set, for each incremental backup, hard links are made in the new backup to all files that were not extracted during the incremental backups. The means the incremental backup looks like a complete image of the PC (with the exception that files that were removed on the PC since the last full backup will still appear in the backup directory tree).

    As of v1.03, the CGI interface knows how to merge unfilled incremental backups will the most recent prior filled (full) backup, giving the incremental backups a filled appearance. The default for $Conf{IncrFill} is off, since there is now no need to fill incremental backups. This saves some level of disk activity, since lots of extra hardlinks are no longer needed (and don't have to be deleted when the backup expires).

  4. BackupPC_trashClean is always run in the background to remove any expired backups. Every 5 minutes it wakes up and removes all the files in /var/lib/backuppc/trash.

    Also, once each night, BackupPC_nightly is run to complete some additional administrative tasks, such as cleaning the pool. This involves removing any files in the pool that only have a single hard link (meaning no backups are using that file). Again, to avoid race conditions, BackupPC_nightly is only run when there are no BackupPC_dump or BackupPC_link processes running.

BackupPC also listens for TCP connections on $Conf{ServerPort}, which is used by the CGI script BackupPC_Admin for status reporting and user-initiated backup or backup cancel requests.

Storage layout

BackupPC resides in three directories:

/usr/share/backuppc
Perl scripts comprising BackupPC reside in /usr/share/backuppc/bin, libraries are in /usr/share/backuppc/lib and documentation is in /usr/share/backuppc/doc.

/usr/share/backuppc/cgi-bin
The CGI script BackupPC_Admin resides in this cgi binary directory.

/var/lib/backuppc
All of BackupPC's data (PC backup images, logs, configuration information) is stored below this directory.

Below /var/lib/backuppc are several directories:

/var/lib/backuppc/conf
The directory /var/lib/backuppc/conf contains:
config.pl
Configuration file. See Configuration file below for more details.

hosts
Hosts file, which lists all the PCs to backup.

/var/lib/backuppc/log
The directory /var/lib/backuppc/log contains:
LOG
Current (today's) log file output from BackupPC.

LOG.0 or LOG.0.z
Yesterday's log file output. Log files are aged daily and compressed (if compression is enabled), and old LOG files are deleted.

BackupPC.pid
Contains BackupPC's process id.

status.pl
A summary of BackupPC's status written periodically by BackupPC so that certain state information can be maintained if BackupPC is restarted. Should not be edited.

UserEmailInfo.pl
A summary of what email was last sent to each user, and when the last email was sent. Should not be edited.

/var/lib/backuppc/trash
Any directories and files below this directory are periodically deleted whenever BackupPC_trashClean checks. When a backup is aborted or when an old backup expires, BackupPC_dump simply moves the directory to /var/lib/backuppc/trash for later removal by BackupPC_trashClean.

/var/lib/backuppc/pool
All uncompressed files from PC backups are stored below /var/lib/backuppc/pool. Each file's name is based on the MD5 hex digest of the file contents. Specifically, for files less than 256K, the file length and the entire file is used. For files up to 1MB, the file length and the first and last 128K are used. Finally, for files longer than 1MB, the file length, and the first and eighth 128K chunks for the file are used.

Each file is stored in a subdirectory X/Y/Z, where X, Y, Z are the first 3 hex digits of the MD5 digest.

For example, if a file has an MD5 digest of 123456789abcdef0, the file is stored in /var/lib/backuppc/pool/1/2/3/123456789abcdef0.

The MD5 digest might not be unique (especially since not all the file's contents are used for files bigger than 256K). Different files that have the same MD5 digest are stored with a trailing suffix ``_n'' where n is an incrementing number starting at 0. So, for example, if two additional files were identical to the first, except the last byte was different, and assuming the file was larger than 1MB (so the MD5 digests are the same but the files are actually different), the three files would be stored as:

        /var/lib/backuppc/pool/1/2/3/123456789abcdef0
        /var/lib/backuppc/pool/1/2/3/123456789abcdef0_0
        /var/lib/backuppc/pool/1/2/3/123456789abcdef0_1

Both BackupPC_dump (actually, BackupPC_tarExtract) and BackupPC_link are responsible for checking newly backed up files against the pool. For each file, the MD5 digest is used to generate a file name in the pool directory. If the file exists in the pool, the contents are compared. If there is no match, additional files ending in ``_n'' are checked. (Actually, BackupPC_tarExtract compares multiple candidate files in parallel.) If the file contents exactly match, the file is created by simply making a hard link to the pool file (this is done by BackupPC_tarExtract as the backup proceeds). Otherwise, BackupPC_tarExtract writes the new file to disk and a new hard link is made in the pool to the file (this is done later by BackupPC_link).

Therefore, every file in the pool will have at least 2 hard links (one for the pool file and one for the backup file below /var/lib/backuppc/pc). Identical files from different backups or PCs will all be linked to the same file. When old backups are deleted, some files in the pool might only have one link. BackupPC_nightly checks the entire pool and removes all files that have only a single link, thereby recovering the storage for that file.

One other issue: zero length files are not pooled, since there are a lot of these files and on most file systems it doesn't save any disk space to turn these files into hard links.

/var/lib/backuppc/cpool
All compressed files from PC backups are stored below /var/lib/backuppc/cpool. Its layout is the same as /var/lib/backuppc/pool, and the hashing function is the same (and, importantly, based on the uncompressed file, not the compressed file).

/var/lib/backuppc/pc/$host
For each PC $host, all the backups for that PC are stored below the directory /var/lib/backuppc/pc/$host. This directory contains the following files:
LOG
Current log file for this PC from BackupPC_dump.

LOG.0 or LOG.0.z
Last month's log file. Log files are aged monthly and compressed (if compression is enabled), and old LOG files are deleted.

XferERR or XferERR.z
Output from the transport program (ie: smbclient or tar) for the most recent failed backup.

new
Subdirectory in which the current backup is stored. This directory is renamed if the backup succeeds.

XferLOG or XferLOG.z
Output from the transport program (ie: smbclient or tar) for the current backup.

nnn (an integer)
Successful backups are in directories numbered sequentially starting at 0.

XferLOG.nnn or XferLOG.nnn.z
Output from the transport program (ie: smbclient or tar) corresponding to backup number nnn.

RestoreInfo.nnn
Information about restore request #nnn including who, what, when, and why. This file is in Data::Dumper format. (Note that the restore numbers are not related to the backup number.)

RestoreLOG.nnn.z
Output from smbclient or tar during restore #nnn. (Note that the restore numbers are not related to the backup number.)

config.pl
Optional configuration settings specific to this host. Settings in this file override the main configuration file.

backups
A tab-delimited ascii table listing information about each successful backup, one per row. The columns are:
num
The backup number, an integer that starts at 0 and increments for each successive backup. The corresponding backup is stored in the directory num (eg: if this field is 5, then the backup is stored in /var/lib/backuppc/pc/$host/5).

type
Set to ``full'' or ``incr'' for full or incremental backup.

startTime
Start time of the backup in unix seconds.

endTime
Stop time of the backup in unix seconds.

nFiles
Number of files backed up (as reported by smbclient or tar).

size
Total file size backed up (as reported by smbclient or tar).

nFilesExist
Number of files that were already in the pool (as determined by BackupPC_dump and BackupPC_link).

sizeExist
Total size of files that were already in the pool (as determined by BackupPC_dump and BackupPC_link).

nFilesNew
Number of files that were not in the pool (as determined by BackupPC_link).

sizeNew
Total size of files that were not in the pool (as determined by BackupPC_link).

xferErrs
Number of errors or warnings from smbclient (zero for tar).

xferBadFile
Number of errors from smbclient that were bad file errors (zero for tar).

xferBadShare
Number of errors from smbclient that were bad share errors (zero for tar).

tarErrs
Number of errors from BackupPC_tarExtract.

compress
The compression level used on this backup. Zero or empty means no compression.

sizeExistComp
Total compressed size of files that were already in the pool (as determined by BackupPC_dump and BackupPC_link).

sizeNewComp
Total compressed size of files that were not in the pool (as determined by BackupPC_link).

noFill
Set if this backup has not been filled in with the most recent previous filled or full backup. See $Conf{IncrFill}.

fillFromNum
If this backup was filled (ie: noFill is 0) then this is the number of the backup that it was filled from

mangle
Set if this backup has mangled file names and attributes. Always true for backups in v1.4.0 and above. False for all backups prior to v1.4.0.

xferMethod
Set to the value of $Conf{XferMethod} when this dump was done.

level
The level of this dump. A full dump is level 0. Currently incrementals are 1. But when multi-level incrementals are supported this will reflect each dump's incremental level.

restores
A tab-delimited ascii table listing information about each requested restore, one per row. The columns are:
num
Restore number (matches the suffix of the RestoreInfo.nnn and RestoreLOG.nnn.z file), unrelated to the backup number.

startTime
Start time of the restore in unix seconds.

endTime
End time of the restore in unix seconds.

result
Result (ok or failed).

errorMsg
Error message if restore failed.

nFiles
Number of files restored.

size
Size in bytes of the restored files.

tarCreateErrs
Number of errors from BackupPC_tarCreate during restore.

xferErrs
Number of errors from smbclient or tar during restore.

Compressed file format

The compressed file format is as generated by Compress::Zlib::deflate with one minor, but important, tweak. Since Compress::Zlib::inflate fully inflates its argument in memory, it could take large amounts of memory if it was inflating a highly compressed file. For example, a 200MB file of 0x0 bytes compresses to around 200K bytes. If Compress::Zlib::inflate was called with this single 200K buffer, it would need to allocate 200MB of memory to return the result.

BackupPC watches how efficiently a file is compressing. If a big file has very high compression (meaning it will use too much memory when it is inflated), BackupPC calls the flush() method, which gracefully completes the current compression. BackupPC then starts another deflate and simply appends the output file. So the BackupPC compressed file format is one or more concatenated deflations/flushes. The specific ratios that BackupPC uses is that if a 6MB chunk compresses to less than 64K then a flush will be done.

Back to the example of the 200MB file of 0x0 bytes. Adding flushes every 6MB adds only 200 or so bytes to the 200K output. So the storage cost of flushing is negligible.

To easily decompress a BackupPC compressed file, the script BackupPC_zcat can be found in /usr/share/backuppc/bin. For each file name argument it inflates the file and writes it to stdout.

File name mangling

Backup file names are stored in ``mangled'' form. Each node of a path is preceded by ``f'' (mnemonic: file), and special characters (\n, \r, % and /) are URI-encoded as ``%xx'', where xx is the ascii character's hex value. So c:/craig/example.txt is now stored as fc/fcraig/fexample.txt.

This was done mainly so meta-data could be stored alongside the backup files without name collisions. In particular, the attributes for the files in a directory are stored in a file called ``attrib'', and mangling avoids file name collisions (I discarded the idea of having a duplicate directory tree for every backup just to store the attributes). Other meta-data (eg: rsync checksums) could be stored in file names preceded by, eg, ``c''. There are two other benefits to mangling: the share name might contain ``/'' (eg: ``/home/craig'' for tar transport), and I wanted that represented as a single level in the storage tree. Secondly, as files are written to NewFileList for later processing by BackupPC_link, embedded newlines in the file's path will cause problems which are avoided by mangling.

The CGI script undoes the mangling, so it is invisible to the user. Old (unmangled) backups are still supported by the CGI interface.

Special files

Linux/unix file systems support several special file types: symbolic links, character and block device files, fifos (pipes) and unix-domain sockets. All except unix-domain sockets are supported by BackupPC (there's no point in backing up or restoring unix-domain sockets since they only have meaning after a process creates them). Symbolic links are stored as a plain file whose contents are the contents of the link (not the file it points to). This file is compressed and pooled like any normal file. Character and block device files are also stored as plain files, whose contents are two integers separated by a comma; the numbers are the major and minor device number. These files are compressed and pooled like any normal file. Fifo files are stored as empty plain files (which are not pooled since they have zero size). In all cases, the original file type is stored in the attrib file so it can be correctly restored.

Hardlinks are also supported. When GNU tar first encounters a file with more than one link (ie: hardlinks) it dumps it as a regular file. When it sees the second and subsequent hardlinks to the same file, it dumps just the hardlink information. BackupPC correctly recognizes these hardlinks and stores them just like symlinks: a regular text file whose contents is the path of the file linked to. The CGI script will download the original file when you click on a hardlink.

Also, BackupPC_tarCreate has enough magic to re-create the hardlinks dynamically based on whether or not the original file and hardlinks are both included in the tar file. For example, imagine a/b/x is a hardlink to a/c/y. If you use BackupPC_tarCreate to restore directory a, then the tar file will include a/b/x as the original file and a/c/y will be a hardlink to a/b/x. If, instead you restore a/c, then the tar file will include a/c/y as the original file, not a hardlink.

Attribute file format

The unix attributes for the contents of a directory (all the files and directories in that directory) are stored in a file called attrib. There is a single attrib file for each directory in a backup. For example, if c:/craig contains a single file c:/craig/example.txt, that file would be stored as fc/fcraig/fexample.txt and there would be an attribute file in fc/fcraig/attrib (and also fc/attrib and ./attrib). The file fc/fcraig/attrib would contain a single entry containing the attributes for fc/fcraig/fexample.txt.

The attrib file starts with a magic number, followed by the concatenation of the following information for each file:

The attrib file is also compressed if compression is enabled. See the lib/BackupPC/Attrib.pm module for full details.

Attribute files are pooled just like normal backup files. This saves space if all the files in a directory have the same attributes across multiple backups, which is common.

Optimizations

BackupPC doesn't care about the access time of files in the pool since it saves attribute meta-data separate from the files. Since BackupPC mostly does reads from disk, maintaining the access time of files generates a lot of unnecessary disk writes. So, provided BackupPC has a dedicated data disk, you should consider mounting BackupPC's data directory with the noatime attribute (see mount(1)).

Limitations

BackupPC isn't perfect (but it is getting better). Here are some limitations of BackupPC:

Non-unix file attributes not backed up
smbclient doesn't extract the WinXX ACLs, so file attributes other than the equivalent (as provided by smbclient) unix attributes are not backed up.

Locked files are not backed up
Under WinXX a locked file cannot be read by smbclient. Such files will not be backed up. This includes the WinXX system registry files.

This is especially troublesome for Outlook, which stores all its data in a single large file and keeps it locked whenever it is running. Since many users keep Outlook running all the time their machine is up their Outlook file will not be backed up. Sadly, this file is the most important file to backup. As one workaround, Microsoft has a user-level application that periodically asks the user if they want to make a copy of their outlook.pst file. This copy can then be backed up by BackupPC. See http://office.microsoft.com/downloads/2002/pfbackup.aspx.

Similarly, all of the data for WinXX services like SQL databases, Exchange etc won't be backed up. If these applications support some kind of export or utility to save their data to disk then this can =used to create files that BackupPC can backup.

So far, the best that BackupPC can do is send warning emails to the user saying that their outlook files haven't been backed up in X days. (X is configurable.) The message invites the user to exit Outlook and gives a URL to manually start a backup.

I suspect there is a way of mirroring the outlook.pst file so that at least the mirror copy can be backed up. Or perhaps a manual copy can be started at login. Does some WinXX expert know how to do this?

Comment: two users have noted that there are commercial OFM (open file manager) products that are designed to solve this problem, for example from St. Bernard or Columbia Data Products. Apparently Veritas and Legato bundle this product with their commercial products. See for example http://www.stbernard.com/products/docs/ofm_whitepaperV8.pdf. If anyone tries these programs with BackupPC please tell us whether or not they work.

Don't expect to reconstruct a complete WinXX drive
The conclusion from the last few items is that BackupPC is not intended to allow a complete WinXX disk to be re-imaged from the backup. Our approach to system restore in the event of catastrophic failure is to re-image a new disk from a generic master, and then use the BackupPC archive to restore user files.

It is likely that linux/unix backups done using tar (rather than smb) can be used to reconstruct a complete file system, although I haven't tried it.

Maximum Backup File Sizes
BackupPC can backup and manage very large file sizes, probably as large as 2^51 bytes (when a double-precision number's mantissa can no longer represent an integer exactly). In practice, several things outside BackupPC limit the maximum individual file size. Any one of the following items will limit the maximum individual file size:
Perl
Perl needs to be compiled with uselargefiles defined. Check your installation with:
    perl -V | egrep largefiles

Without this, the maximum file size will be 2GB.

File system
The BackupPC pool and data directories must be on a file system that supports large files.

Without this, the maximum file size will be 2GB.

Transport
The transport mechanism also limits the maximum individual file size.

GNU tar maximum file size is limited by the tar header format. The tar header uses 11 octal digits to represent the file size, which is 33 bits or 8GB. But GNU tar has a binary file size convention for files bigger than 8GB, which is supported in BackupPC as of 2.0.1. So GNU tar can support very large files.

Smbclient 2.2.x is limited to 4GB file sizes. Moreover, a bug in smbclient (mixing signed and unsigned 32 bit values) causes it to incorrectly do the tar octal conversion for file sizes from 2GB-4GB. Up to 2.0.0, BackupPC_tarExtract knows about this bug and can recover the correct file size. So smbclient 2.2.x transport works up to 4GB file sizes with BackupPC 2.0.0.

But as of BackupPC 2.0.1 this repair was removed. The reason is that smbclient 3.0.x now supports large files, so it can validly generate file sizes that would have been incorrectly ``repaired'' by BackupPC_tarExtract. So with smbclient 3.0.x and BackupPC 2.0.1 or later, files bigger than 4GB are supported. Files larger than 8GB have been tested, provided the patch in this smbclient bug is applied to samba 3.0.0:

    https://bugzilla.samba.org/show_bug.cgi?id=563

However, due to some bug in smbclient, restores only work up to 2GB file sizes. This is mentioned in this bug report.

Rsync running on linux supports large files, bigger than 4GB. Cygwin 1.3.x is limited to either 2GB or 4GB file sizes. Cygwin 1.5.x allows large file support but I haven't tested it yet with rsync. More testing needs to be done to verify the file size limit for rsync on various platforms.

Some tape backup systems aren't smart about hard links
If you backup the BackupPC pool to tape you need to make sure that the tape backup system is smart about hard links. For example, if you simply try to tar the BackupPC pool to tape you will backup a lot more data than is necessary.

Using the example at the start of the installation section, 65 hosts are backed up with each full backup averaging 3.2GB. Storing one full backup and two incremental backups per laptop is around 240GB of raw data. But because of the pooling of identical files, only 87GB is used (with compression the total is lower). If you run du or tar on the data directory, there will appear to be 240GB of data, plus the size of the pool (around 87GB), or 327GB total.

If your tape backup system is not smart about hard links an alternative is to periodically backup just the last successful backup for each host to tape. Another alternative is to do a low-level dump of the pool file system (ie: /dev/hda1 or similar) using dump(1).

Supporting more efficient tape backup is an area for further development.

Incremental backups might included deleted files
To make browsing and restoring backups easier, incremental backups are ``filled-in'' from the last complete backup when the backup is browsed or restored.

However, if a file was deleted by a user after the last full backup, that file will still appear in the ``filled-in'' incremental backup. This is not really a specific problem with BackupPC, rather it is a general issue with the full/incremental backup paradigm. This minor problem could be solved by having smbclient list all files when it does the incremental backup. Volunteers anyone?

Comments or suggestions on these issues are welcome.

Security issues

Please read this section and consider each of the issues carefully.

Smb share password
An important security risk is the manner in which the smb share passwords are stored. They are in plain text. As described in Step 3: Setting up config.pl there are four ways to tell BackupPC the smb share password (manually setting an environment variable, setting the environment variable in /etc/init.d/backuppc, putting the password in /var/lib/backuppc/conf/config.pl, or putting the password in /var/lib/backuppc/pc/$host/config.pl). In the latter 3 cases the smb share password appears in plain text in a file.

If you use any of the latter three methods please make sure that the file's permission is appropriately restricted. If you also use RCS or CVS, double check the file permissions of the config.pl,v file.

In future versions there will probably be support for encryption of the smb share password, but a private key will still have to be stored in a protected place. Comments and suggestions are welcome.

BackupPC socket server
In v1.5.0 the primary method for communication between the CGI program (BackupPC_Admin) and the server (BackupPC) is via a unix-domain socket. Since this socket has restricted permissions, no local user should be able to connect to this port. No backup or restore data passes through this interface, but an attacker can start or stop backups and get status through this port.

If the Apache server and BackupPC_Admin run on a different host to BackupPC then a TCP port must be enabled by setting $Conf{ServerPort}. Anyone can connect to this port. To avoid possible attacks via the TCP socket interface, every client message is protected by an MD5 digest. The MD5 digest includes four items:

The message is sent in plain text preceded by the MD5 digest. A snooper can see the plain-text seed sent by BackupPC and plain-text message from the client, but cannot construct a valid MD5 digest since the secret in $Conf{ServerMesgSecret} is unknown. A replay attack is not possible since the seed changes on a per-connection and per-message basis.

So if you do enable the TCP port, please set $Conf{ServerMesgSecret} to some hard-to-guess string. A denial-of-service attack is possible with the TCP port enabled. Someone could simply connect many times to this port, until BackupPC had exhausted all its file descriptors, and this would cause new backups and the CGI interface to fail. The most secure solution is to run BackupPC and Apache on the same machine and disable the TCP port.

By the way, if you have upgraded from a version of BackupPC prior to v1.5.0 you should set $Conf{ServerPort} to -1 to disable the TCP port.

Installation permissions
It is important to check that the BackupPC scripts in /usr/share/backuppc/bin and /usr/share/backuppc/lib cannot be edited by normal users. Check the directory permissions too.

Pool permissions
It is important to check that the data files in /var/lib/backuppc/pool, /var/lib/backuppc/pc and /var/lib/backuppc/trash cannot be read by normal users. Normal users should not be able to see anything below /var/lib/backuppc.

Host shares
Enabling shares on hosts carries security risks. If you are on a private network and you generally trust your users then there should not be a problem. But if you have a laptop that is sometimes on public networks (eg: broadband or even dialup) you should be concerned. A conservative approach is to use firewall software, and only enable the netbios and smb ports (137 and 139) on connections from the host running BackupPC.

SSH key security
Using ssh for linux/unix clients is quite secure, but the security is only as good as the protection of ssh's private keys. If an attacker can devise a way to run a shell as the BackupPC user then they will have access to BackupPC's private ssh keys. They can then, in turn, ssh to any client machine as root (or whichever user you have configured BackupPC to use). This represents a serious compromise of your entire network. So in vulnerable networks, think carefully about how to protect the machine running BackupPC and how to prevent attackers from gaining shell access (as the BackupPC user) to the machine.

CGI interface
The CGI interface, /usr/share/backuppc/cgi-bin/BackupPC_Admin, needs access to the pool files so it is installed setuid to backuppc. The permissions of this file need to checked carefully. It should be owned by backuppc and have user and group (but not other) execute permission. To allow apache/httpd to execute it, the group ownership should be something that apache/httpd belongs to.

The Apache configuration should be setup for AuthConfig style, using a .htaccess file so that the user's name is passed into the script as $ENV{REMOTE_USER}.

If normal users could directly run BackupPC_Admin then there is a serious security hole: since it is setuid to backuppc any user can browse and restore any backups. Be aware that anyone who is allowed to edit or create cgi scripts on your server can execute BackupPC_Admin as any user! They simply write a cgi script that sets $ENV{REMOTE_USER} and then execs BackupPC_Admin. The exec succeeds since httpd runs the first script as user httpd/apache, which in turn has group permission to execute BackupPC_Admin.

While this setup should be safe, a more conservative approach is to run a dedicated Apache as user backuppc on a different port. Then BackupPC_Admin no longer needs to be setuid, and the cgi directories can be locked down from normal users. Moreover, this setup is exactly the one used to support mod_perl, so this provides both the highest performance and the lowest security risk.

Comments and suggestions are welcome.

Back to Top


Configuration File

The BackupPC configuration file resides in /var/lib/backuppc/conf/config.pl. Optional per-PC configuration files reside in /var/lib/backuppc/pc/$host/config.pl. This file can be used to override settings just for a particular PC.

Modifying the main configuration file

The configuration file is a perl script that is executed by BackupPC, so you should be careful to preserve the file syntax (punctuation, quotes etc) when you edit it. It is recommended that you use CVS, RCS or some other method of source control for changing config.pl.

BackupPC reads or re-reads the main configuration file and the hosts file in three cases:

Whenever you change the configuration file you can either do a kill -HUP BackupPC_pid or simply wait until the next regular wakeup period.

Each time the configuration file is re-read a message is reported in the LOG file, so you can tail it (or view it via the CGI interface) to make sure your kill -HUP worked. Errors in parsing the configuration file are also reported in the LOG file.

The optional per-PC configuration file (/var/lib/backuppc/pc/$host/config.pl) is read whenever it is needed by BackupPC_dump, BackupPC_link and others.

Configuration file includes

If you have a heterogeneous set of clients (eg: a variety of WinXX and linux/unix machines) you will need to create host-specific config.pl files for some or all of these machines to customize the default settings from the master config.pl file (at a minimum to set $Conf{XferMethod}).

Since the config.pl file is just regular perl code, you can include one config file from another. For example, imagine you had three general classes of machines: WinXX desktops, linux machines in the DMZ and linux desktops. You could create three config files in /var/lib/backuppc/conf:

    /var/lib/backuppc/conf/ConfigWinDesktop.pl
    /var/lib/backuppc/conf/ConfigLinuxDMZ.pl
    /var/lib/backuppc/conf/ConfigLinuxDesktop.pl

From each client's directory you can either add a symbolic link to the appropriate config file:

    cd /var/lib/backuppc/pc/$host
    ln -s ../../conf/ConfigWinDesktop.pl config.pl

or, better yet, create a config.pl file in /var/lib/backuppc/pc/$host that includes the default config.pl file using perl's ``do'' command:

    do "/var/lib/backuppc/conf/ConfigWinDesktop.pl";

This alternative allows you to set other configuration options specific to each host after the ``do'' command (perhaps even overriding the settings in the included file).

Note that you could also include snippets of configuration settings from the main configuration file. However, be aware that the modification-time checking that BackupPC does only applies to the main configuration file: if you change one of the included files, BackupPC won't notice. You will need to either touch the main configuration file too, or send BackupPC a HUP (-1) signal.

Back to Top


Configuration Parameters

The configuration parameters are divided into five general groups. The first group (general server configuration) provides general configuration for BackupPC. The next two groups describe what to backup, when to do it, and how long to keep it. The fourth group are settings for email reminders, and the final group contains settings for the CGI interface.

All configuration settings in the second through fifth groups can be overridden by the per-PC config.pl file.

General server configuration

$Conf{ServerHost} = '';
Host name on which the BackupPC server is running.

$Conf{ServerPort} = -1;
TCP port number on which the BackupPC server listens for and accepts connections. Normally this should be disabled (set to -1). The TCP port is only needed if apache runs on a different machine from BackupPC. In that case, set this to any spare port number over 1024 (eg: 2359). If you enable the TCP port, make sure you set $Conf{ServerMesgSecret} too!

$Conf{ServerMesgSecret} = '';
Shared secret to make the TCP port secure. Set this to a hard to guess string if you enable the TCP port (ie: $Conf{ServerPort} > 0).

To avoid possible attacks via the TCP socket interface, every client message is protected by an MD5 digest. The MD5 digest includes four items: - a seed that is sent to the client when the connection opens - a sequence number that increments for each message - a shared secret that is stored in $Conf{ServerMesgSecret} - the message itself.

The message is sent in plain text preceded by the MD5 digest. A snooper can see the plain-text seed sent by BackupPC and plain-text message from the client, but cannot construct a valid MD5 digest since the secret $Conf{ServerMesgSecret} is unknown. A replay attack is not possible since the seed changes on a per-connection and per-message basis.

$Conf{MyPath} = '/bin';
PATH setting for BackupPC. An explicit value is necessary for taint mode. Value shouldn't matter too much since all execs use explicit paths. However, taint mode in perl will complain if this directory is world writable.

$Conf{UmaskMode} = 027;
Permission mask for directories and files created by BackupPC. Default value prevents any access from group other, and prevents group write.

$Conf{WakeupSchedule} = [1..23];
Times at which we wake up, check all the PCs, and schedule necessary backups. Times are measured in hours since midnight. Can be fractional if necessary (eg: 4.25 means 4:15am).

If the hosts you are backing up are always connected to the network you might have only one or two wakeups each night. This will keep the backup activity after hours. On the other hand, if you are backing up laptops that are only intermittently connected to the network you will want to have frequent wakeups (eg: hourly) to maximized the chance that each laptop is backed up.

Examples:

    $Conf{WakeupSchedule} = [22.5];         # once per day at 10:30 pm.
    $Conf{WakeupSchedule} = [1..23];        # every hour except midnight
    $Conf{WakeupSchedule} = [2,4,6,8,10,12,14,16,18,20,22];  # every 2 hours

The default value is every hour except midnight.

$Conf{MaxBackups} = 4;
Maximum number of simultaneous backups to run. If there are no user backup requests then this is the maximum number of simultaneous backups.

$Conf{MaxUserBackups} = 4;
Additional number of simultaneous backups that users can run. As many as $Conf{MaxBackups} + $Conf{MaxUserBackups} requests can run at the same time.

$Conf{MaxPendingCmds} = 10;
Maximum number of pending link commands. New backups will only be started if there are no more than $Conf{MaxPendingCmds} plus $Conf{MaxBackups} number of pending link commands, plus running jobs. This limit is to make sure BackupPC doesn't fall too far behind in running BackupPC_link commands.

$Conf{MaxOldLogFiles} = 14;
Maximum number of log files we keep around in log directory. These files are aged nightly. A setting of 14 means the log directory will contain about 2 weeks of old log files, in particular at most the files LOG, LOG.0, LOG.1, ... LOG.13 (except today's LOG, these files will have a .z extension if compression is on).

If you decrease this number after BackupPC has been running for a while you will have to manually remove the older log files.

$Conf{DfPath} = '/bin/df';
Full path to the df command. Security caution: normal users should not allowed to write to this file or directory.

$Conf{DfCmd} = '$dfPath $topDir';
Command to run df. The following variables are substituted at run-time:
  $dfPath      path to df ($Conf{DfPath})
  $topDir      top-level BackupPC data directory

$Conf{DfMaxUsagePct} = 95;
Maximum threshold for disk utilization on the /var/lib/backuppc filesystem. If the output from $Conf{DfPath} reports a percentage larger than this number then no new regularly scheduled backups will be run. However, user requested backups (which are usually incremental and tend to be small) are still performed, independent of disk usage. Also, currently running backups will not be terminated when the disk usage exceeds this number.

$Conf{TrashCleanSleepSec} = 300;
How long BackupPC_trashClean sleeps in seconds between each check of the trash directory. Once every 5 minutes should be reasonable.

$Conf{DHCPAddressRanges} = [];
List of DHCP address ranges we search looking for PCs to backup. This is an array of hashes for each class C address range. This is only needed if hosts in the conf/hosts file have the dhcp flag set.

Examples:

   # to specify 192.10.10.20 to 192.10.10.250 as the DHCP address pool
   $Conf{DHCPAddressRanges} = [
       {
           ipAddrBase => '192.10.10',
           first => 20,
           last  => 250,
       },
   ];
   # to specify two pools (192.10.10.20-250 and 192.10.11.10-50)
   $Conf{DHCPAddressRanges} = [
       {
           ipAddrBase => '192.10.10',
           first => 20,
           last  => 250,
       },
       {
           ipAddrBase => '192.10.11',
           first => 10,
           last  => 50,
       },
   ];

$Conf{BackupPCUser} = '';
$Conf{CgiDir} = '';
$Conf{InstallDir} = '';
These configuration settings aren't used by BackupPC, but simply remember a few settings used by configure.pl during installation. These are used by configure.pl when upgrading to new versions of BackupPC.

$Conf{BackupPCUserVerify} = 1;
Whether BackupPC and the CGI script BackupPC_Admin verify that they are really running as user $Conf{BackupPCUser}. If this flag is set and the effective user id (euid) differs from $Conf{BackupPCUser} then both scripts exit with an error. This catches cases where BackupPC might be accidently started as root or the wrong user, or if the CGI script is not installed correctly.

$Conf{HardLinkMax} = 31999;
Maximum number of hardlinks supported by the $TopDir file system that BackupPC uses. Most linux or unix file systems should support at least 32000 hardlinks per file, or 64K in other cases. If a pool file already has this number of hardlinks, a new pool file is created so that new hardlinks can be accommodated. This limit will only be hit if an identical file appears at least this number of times across all the backups.

What to backup and when to do it

$Conf{SmbShareName} = 'C$';
Name of the host share that is backed up when using SMB. This can be a string or an array of strings if there are multiple shares per host. Examples:
  $Conf{SmbShareName} = 'c';          # backup 'c' share
  $Conf{SmbShareName} = ['c', 'd'];   # backup 'c' and 'd' shares

This setting only matters if $Conf{XferMethod} = 'smb'.

$Conf{SmbShareUserName} = '';
Smbclient share user name. This is passed to smbclient's -U argument.

This setting only matters if $Conf{XferMethod} = 'smb'.

$Conf{SmbSharePasswd} = '';
Smbclient share password. This is passed to smbclient via its PASSWD environment variable. There are several ways you can tell BackupPC the smb share password. In each case you should be very careful about security. If you put the password here, make sure that this file is not readable by regular users! See the ``Setting up config.pl'' section in the documentation for more information.

This setting only matters if $Conf{XferMethod} = 'smb'.

$Conf{TarShareName} = '/';
Which host directories to backup when using tar transport. This can be a string or an array of strings if there are multiple directories to backup per host. Examples:
  $Conf{TarShareName} = '/';                    # backup everything
  $Conf{TarShareName} = '/home';                # only backup /home
  $Conf{TarShareName} = ['/home', '/src'];      # backup /home and /src

The fact this parameter is called 'TarShareName' is for historical consistency with the Smb transport options. You can use any valid directory on the client: there is no need for it to correspond to any Smb share or device mount point.

Note also that you can also use $Conf{BackupFilesOnly} to specify a specific list of directories to backup. It's more efficient to use this option instead of $Conf{TarShareName} since a new tar is run for each entry in $Conf{TarShareName}.

On the other hand, if you add --one-file-system to $Conf{TarClientCmd} you can backup each file system separately, which makes restoring one bad file system easier. In this case you would list all of the mount points here, since you can't get the same result with $Conf{BackupFilesOnly}:

    $Conf{TarShareName} = ['/', '/var', '/data', '/boot'];

This setting only matters if $Conf{XferMethod} = 'tar'.

$Conf{FullPeriod} = 6.97;
Minimum period in days between full backups. A full dump will only be done if at least this much time has elapsed since the last full dump, and at least $Conf{IncrPeriod} days has elapsed since the last successful dump.

Typically this is set slightly less than an integer number of days. The time taken for the backup, plus the granularity of $Conf{WakeupSchedule} will make the actual backup interval a bit longer.

There are two special values for $Conf{FullPeriod}:

  -1   Don't do any regular backups on this machine.  Manually
       requested backups (via the CGI interface) will still occur.
  -2   Don't do any backups on this machine.  Manually requested
       backups (via the CGI interface) will be ignored.

These special settings are useful for a client that is no longer being backed up (eg: a retired machine), but you wish to keep the last backups available for browsing or restoring to other machines.

Also, you might create a virtual client (by setting $Conf{ClientNameAlias}) for restoring to a DVD or permanent media and you would set $Conf{FullPeriod} to -2 so that it is never backed up.

$Conf{IncrPeriod} = 0.97;
Minimum period in days between incremental backups (a user requested incremental backup will be done anytime on demand).

Typically this is set slightly less than an integer number of days. The time taken for the backup, plus the granularity of $Conf{WakeupSchedule} will make the actual backup interval a bit longer.

$Conf{FullKeepCnt} = 1;
Number of full backups to keep. Must be >= 1.

In the steady state, each time a full backup completes successfully the oldest one is removed. If this number is decreased, the extra old backups will be removed.

If filling of incremental dumps is off the oldest backup always has to be a full (ie: filled) dump. This might mean an extra full dump is kept until the second oldest (incremental) dump expires.

$Conf{FullKeepCntMin} = 1;
$Conf{FullAgeMax} = 60;
Very old full backups are removed after $Conf{FullAgeMax} days. However, we keep at least $Conf{FullKeepCntMin} full backups no matter how old they are.

$Conf{IncrKeepCnt} = 6;
Number of incremental backups to keep. Must be >= 1.

In the steady state, each time an incr backup completes successfully the oldest one is removed. If this number is decreased, the extra old backups will be removed.

$Conf{IncrKeepCntMin} = 1;
$Conf{IncrAgeMax} = 30;
Very old incremental backups are removed after $Conf{IncrAgeMax} days. However, we keep at least $Conf{IncrKeepCntMin} incremental backups no matter how old they are.

$Conf{IncrFill} = 0;
Whether incremental backups are filled. ``Filling'' means that the most recent full (or filled) dump is merged into the new incremental dump using hardlinks. This makes an incremental dump look like a full dump. Prior to v1.03 all incremental backups were filled. In v1.4.0 and later the default is off.

BackupPC, and the cgi interface in particular, do the right thing on un-filled incremental backups. It will correctly display the merged incremental backup with the most recent filled backup, giving the un-filled incremental backups a filled appearance. That means it invisible to the user whether incremental dumps are filled or not.

Filling backups takes a little extra disk space, and it does cost some extra disk activity for filling, and later removal. Filling is no longer useful, since file mangling and compression doesn't make a filled backup very useful. It's likely the filling option will be removed from future versions: filling will be delegated to the display and extraction of backup data.

If filling is off, BackupPC makes sure that the oldest backup is a full, otherwise the following incremental backups will be incomplete. This might mean an extra full backup has to be kept until the following incremental backups expire.

The default is off. You can turn this on or off at any time without affecting existing backups.

$Conf{RestoreInfoKeepCnt} = 10;
Number of restore logs to keep. BackupPC remembers information about each restore request. This number per client will be kept around before the oldest ones are pruned.

Note: files/dirs delivered via Zip or Tar downloads don't count as restores. Only the first restore option (where the files and dirs are written to the host) count as restores that are logged.

$Conf{BackupFilesOnly} = undef;
List of directories or files to backup. If this is defined, only these directories or files will be backed up.

For Smb, only one of $Conf{BackupFilesExclude} and $Conf{BackupFilesOnly} can be specified per share. If both are set for a particular share, then $Conf{BackupFilesOnly} takes precedence and $Conf{BackupFilesExclude} is ignored.

This can be set to a string, an array of strings, or, in the case of multiple shares, a hash of strings or arrays. A hash is used to give a list of directories or files to backup for each share (the share name is the key). If this is set to just a string or array, and $Conf{SmbShareName} contains multiple share names, then the setting is assumed to apply to only the first share name.

Examples:

   $Conf{BackupFilesOnly} = '/myFiles';
   $Conf{BackupFilesOnly} = ['/myFiles'];     # same as first example
   $Conf{BackupFilesOnly} = ['/myFiles', '/important'];
   $Conf{BackupFilesOnly} = {
      'c' => ['/myFiles', '/important'],      # these are for 'c' share
      'd' => ['/moreFiles', '/archive'],      # these are for 'd' share
   };

$Conf{BackupFilesExclude} = undef;
List of directories or files to exclude from the backup. For Smb, only one of $Conf{BackupFilesExclude} and $Conf{BackupFilesOnly} can be specified per share. If both are set for a particular share, then $Conf{BackupFilesOnly} takes precedence and $Conf{BackupFilesExclude} is ignored.

This can be set to a string, an array of strings, or, in the case of multiple shares, a hash of strings or arrays. A hash is used to give a list of directories or files to exclude for each share (the share name is the key). If this is set to just a string or array, and $Conf{SmbShareName} contains multiple share names, then the setting is assumed to apply to only the first share name.

The exact behavior is determined by the underlying transport program, smbclient or tar. For smbclient the exlclude file list is passed into the X option. Simple shell wild-cards using ``*'' or ``?'' are allowed.

For tar, if the exclude file contains a ``/'' it is assumed to be anchored at the start of the string. Since all the tar paths start with ``./'', BackupPC prepends a ``.'' if the exclude file starts with a ``/''. Note that GNU tar version >= 1.13.7 is required for the exclude option to work correctly. For linux or unix machines you should add ``/proc'' to $Conf{BackupFilesExclude} unless you have specified --one-file-system in $Conf{TarClientCmd} or --one-file-system in $Conf{RsyncArgs}. Also, for tar, do not use a trailing ``/'' in the directory name: a trailing ``/'' causes the name to not match and the directory will not be excluded.

Examples:

   $Conf{BackupFilesExclude} = '/temp';
   $Conf{BackupFilesExclude} = ['/temp'];     # same as first example
   $Conf{BackupFilesExclude} = ['/temp', '/winnt/tmp'];
   $Conf{BackupFilesExclude} = {
      'c' => ['/temp', '/winnt/tmp'],         # these are for 'c' share
      'd' => ['/junk', '/dont_back_this_up'], # these are for 'd' share
   };

$Conf{BlackoutBadPingLimit} = 3;
$Conf{BlackoutGoodCnt} = 7;
PCs that are always or often on the network can be backed up after hours, to reduce PC, network and server load during working hours. For each PC a count of consecutive good pings is maintained. Once a PC has at least $Conf{BlackoutGoodCnt} consecutive good pings it is subject to ``blackout'' and not backed up during hours and days specified by $Conf{BlackoutWeekDays}, $Conf{BlackoutHourBegin} and $Conf{BlackoutHourEnd}.

To allow for periodic rebooting of a PC or other brief periods when a PC is not on the network, a number of consecutive bad pings is allowed before the good ping count is reset. This parameter is $Conf{BlackoutBadPingLimit}.

Note that bad and good pings don't occur with the same interval. If a machine is always on the network, it will only be pinged roughly once every $Conf{IncrPeriod} (eg: once per day). So a setting for $Conf{BlackoutGoodCnt} of 7 means it will take around 7 days for a machine to be subject to blackout. On the other hand, if a ping is failed, it will be retried roughly every time BackupPC wakes up, eg, every one or two hours. So a setting for $Conf{BlackoutBadPingLimit} of 3 means that the PC will lose its blackout status after 3-6 hours of unavailability.

To disable the blackout feature set $Conf{BlackoutGoodCnt} to a negative value. A value of 0 will make all machines subject to blackout. But if you don't want to do any backups during the day it would be easier to just set $Conf{WakeupSchedule} to a restricted schedule.

$Conf{BlackoutHourBegin} = 7.0;
$Conf{BlackoutHourEnd} = 19.5;
$Conf{BlackoutWeekDays} = [1, 2, 3, 4, 5];
The default settings specify the blackout period from 7:00am to 7:30pm local time on Mon-Fri. For $Conf{BlackoutWeekDays}, 0 is Sunday, 1 is Monday etc.

$Conf{BackupZeroFilesIsFatal} = 1;
A backup of a share that has zero files is considered fatal. This is used to catch miscellaneous Xfer errors that result in no files being backed up. If you have shares that might be empty (and therefore an empty backup is valid) you should set this flag to 0.

General per-PC configuration settings

$Conf{XferMethod} = 'smb';
What transport method to use to backup each host. If you have a mixed set of WinXX and linux/unix hosts you will need to override this in the per-PC config.pl.

The valid values are:

  - 'smb':    backup and restore via smbclient and the SMB protocol.
              Best choice for WinXX.
  - 'rsync':  backup and restore via rsync (via rsh or ssh).
              Best choice for linux/unix.  Can also work on WinXX.
  - 'rsyncd': backup and restre via rsync daemon on the client.
              Best choice for linux/unix if you have rsyncd running on
              the client.  Can also work on WinXX.
  - 'tar':    backup and restore via tar, tar over ssh, rsh or nfs.
              Good choice for linux/unix.

$Conf{SmbClientPath} = '/usr/bin/smbclient';
Full path for smbclient. Security caution: normal users should not allowed to write to this file or directory.

smbclient is from the Samba distribution. smbclient is used to actually extract the incremental or full dump of the share filesystem from the PC.

This setting only matters if $Conf{XferMethod} = 'smb'.

$Conf{SmbClientFullCmd} = '$smbClientPath \\\\$host\\$shareName' ...
Commands to run smbclient for a full dump, incremental dump or a restore. This setting only matters if $Conf{XferMethod} = 'smb'.

The following variables are substituted at run-time:

   $smbClientPath   same as $Conf{SmbClientPath}
   $host            host to backup/restore
   $hostIP          host IP address
   $shareName       share name
   $userName        user name
   $fileList        list of files to backup (based on exclude/include)
   $I_option        optional -I option to smbclient
   $X_option        exclude option (if $fileList is an exclude list)
   $timeStampFile   start time for incremental dump

$Conf{TarClientCmd} = '$sshPath -q -n -l root $host' ...
Full command to run tar on the client. GNU tar is required. You will need to fill in the correct paths for ssh2 on the local host (server) and GNU tar on the client. Security caution: normal users should not allowed to write to these executable files or directories.

See the documentation for more information about setting up ssh2 keys.

If you plan to use NFS then tar just runs locally and ssh2 is not needed. For example, assuming the client filesystem is mounted below /mnt/hostName, you could use something like:

   $Conf{TarClientCmd} = '$tarPath -c -v -f - -C /mnt/$host/$shareName'
                       . ' --totals';

In the case of NFS or rsh you need to make sure BackupPC's privileges are sufficient to read all the files you want to backup. Also, you will probably want to add ``/proc'' to $Conf{BackupFilesExclude}.

The following variables are substituted at run-time:

  $host        host name
  $hostIP      host's IP address
  $incrDate    newer-than date for incremental backups
  $shareName   share name to backup (ie: top-level directory path)
  $fileList    specific files to backup or exclude
  $tarPath     same as $Conf{TarClientPath}
  $sshPath     same as $Conf{SshPath}

If a variable is followed by a ``+'' it is shell escaped. This is necessary for the command part of ssh or rsh, since it ends up getting passed through the shell.

This setting only matters if $Conf{XferMethod} = 'tar'.

$Conf{TarFullArgs} = '$fileList+';
Extra tar arguments for full backups. Several variables are substituted at run-time. See $Conf{TarClientCmd} for the list of variable substitutions.

If you are running tar locally (ie: without rsh or ssh) then remove the ``+'' so that the argument is no longer shell escaped.

This setting only matters if $Conf{XferMethod} = 'tar'.

$Conf{TarIncrArgs} = '--newer=$incrDate+ $fileList+';
Extra tar arguments for incr backups. Several variables are substituted at run-time. See $Conf{TarClientCmd} for the list of variable substitutions.

Note that GNU tar has several methods for specifying incremental backups, including:

  --newer-mtime $incrDate+
         This causes a file to be included if the modification time is
         later than $incrDate (meaning its contents might have changed).
         But changes in the ownership or modes will not qualify the
         file to be included in an incremental.
  --newer=$incrDate+
         This causes the file to be included if any attribute of the
         file is later than $incrDate, meaning either attributes or
         the modification time.  This is the default method.  Do
         not use --atime-preserve in $Conf{TarClientCmd} above,
         otherwise resetting the atime (access time) counts as an
         attribute change, meaning the file will always be included
         in each new incremental dump.

If you are running tar locally (ie: without rsh or ssh) then remove the ``+'' so that the argument is no longer shell escaped.

This setting only matters if $Conf{XferMethod} = 'tar'.

$Conf{TarClientRestoreCmd} = '$sshPath -q -l root $host' ...
Full command to run tar for restore on the client. GNU tar is required. This can be the same as $Conf{TarClientCmd}, with tar's -c replaced by -x and ssh's -n removed.

See $Conf{TarClientCmd} for full details.

This setting only matters if $Conf{XferMethod} = ``tar''.

$Conf{TarClientPath} = '/bin/tar';
Full path for tar on the client. Security caution: normal users should not allowed to write to this file or directory.

This setting only matters if $Conf{XferMethod} = 'tar'.

$Conf{RsyncClientPath} = '/bin/rsync';
Path to rsync executable on the client

$Conf{RsyncClientCmd} = '$sshPath -l root $host $rsyncPath $argList+';
Full command to run rsync on the client machine. The following variables are substituted at run-time:
       $host           host name being backed up
       $hostIP         host's IP address
       $shareName      share name to backup (ie: top-level directory path)
       $rsyncPath      same as $Conf{RsyncClientPath}
       $sshPath        same as $Conf{SshPath}
       $argList        argument list, built from $Conf{RsyncArgs},
                       $shareName, $Conf{BackupFilesExclude} and
                       $Conf{BackupFilesOnly}

This setting only matters if $Conf{XferMethod} = 'rsync'.

$Conf{RsyncClientRestoreCmd} = '$sshPath -l root $host $rsyncPath $argList+';
Full command to run rsync for restore on the client. The following variables are substituted at run-time:
       $host           host name being backed up
       $hostIP         host's IP address
       $shareName      share name to backup (ie: top-level directory path)
       $rsyncPath      same as $Conf{RsyncClientPath}
       $sshPath        same as $Conf{SshPath}
       $argList        argument list, built from $Conf{RsyncArgs},
                       $shareName, $Conf{BackupFilesExclude} and
                       $Conf{BackupFilesOnly}

This setting only matters if $Conf{XferMethod} = 'rsync'.

$Conf{RsyncShareName} = '/';
Share name to backup. For $Conf{XferMethod} = ``rsync'' this should be a file system path, eg '/' or '/home'.

For $Conf{XferMethod} = ``rsyncd'' this should be the name of the module to backup (ie: the name from /etc/rsynd.conf).

This can also be a list of multiple file system paths or modules. For example, by adding --one-file-system to $Conf{RsyncArgs} you can backup each file system separately, which makes restoring one bad file system easier. In this case you would list all of the mount points:

    $Conf{RsyncShareName} = ['/', '/var', '/data', '/boot'];

$Conf{RsyncdClientPort} = 873;
Rsync daemon port on the client, for $Conf{XferMethod} = ``rsyncd''.

$Conf{RsyncdUserName} = '';
Rsync daemon user name on client, for $Conf{XferMethod} = ``rsyncd''. The user name and password are stored on the client in whatever file the ``secrets file'' parameter in rsyncd.conf points to (eg: /etc/rsyncd.secrets).

$Conf{RsyncdPasswd} = '';
Rsync daemon user name on client, for $Conf{XferMethod} = ``rsyncd''. The user name and password are stored on the client in whatever file the ``secrets file'' parameter in rsyncd.conf points to (eg: /etc/rsyncd.secrets).

$Conf{RsyncdAuthRequired} = 1;
Whether authentication is mandatory when connecting to the client's rsyncd. By default this is on, ensuring that BackupPC will refuse to connect to an rsyncd on the client that is not password protected. Turn off at your own risk.

$Conf{RsyncArgs} = [ ... ];
Arguments to rsync for backup. Do not edit the first set unless you have a thorough understanding of how File::RsyncP works.

Examples of additional arguments that should work are --exclude/--include, eg:

    $Conf{RsyncArgs} = [
          # original arguments here
          '-v',
          '--exclude', '/proc',
          '--exclude', '*.tmp',
    ];

$Conf{RsyncRestoreArgs} = [ ... ];
Arguments to rsync for restore. Do not edit the first set unless you have a thorough understanding of how File::RsyncP works.

$Conf{RsyncLogLevel} = 1;
Amount of verbosity in Rsync Xfer log files. 0 means be quiet, 1 will give will give one line per file, 2 will also show skipped files on incrementals, higher values give more output. 10 will include byte dumps of all data read/written, which will make the log files huge.

$Conf{SshPath} = '/usr/bin/ssh';
Full path for ssh. Security caution: normal users should not allowed to write to this file or directory.

$Conf{NmbLookupPath} = '/usr/bin/nmblookup';
Full path for nmblookup. Security caution: normal users should not allowed to write to this file or directory.

nmblookup is from the Samba distribution. nmblookup is used to get the netbios name, necessary for DHCP hosts.

$Conf{NmbLookupCmd} = '$nmbLookupPath -A $host';
NmbLookup command. Given an IP address, does an nmblookup on that IP address. The following variables are substituted at run-time:
  $nmbLookupPath      path to nmblookup ($Conf{NmbLookupPath})
  $host               IP address

This command is only used for DHCP hosts: given an IP address, this command should try to find its NetBios name.

$Conf{NmbLookupFindHostCmd} = '$nmbLookupPath $host';
NmbLookup command. Given a netbios name, finds that host by doing a NetBios lookup. Several variables are substituted at run-time:
  $nmbLookupPath      path to nmblookup ($Conf{NmbLookupPath})
  $host               NetBios name

In some cases you might need to change the broadcast address, for example if nmblookup uses 192.168.255.255 by default and you find that doesn't work, try 192.168.1.255 (or your equivalent class C address) using the -B option:

   $Conf{NmbLookupFindHostCmd} = '$nmbLookupPath -B 192.168.1.255 $host';

If you use a WINS server and your machines don't respond to multicast NetBios requests you can use this (replace 1.2.3.4 with the IP address of your WINS server):

   $Conf{NmbLookupFindHostCmd} = '$nmbLookupPath -R -U 1.2.3.4 $host';

This is preferred over multicast since it minimizes network traffic.

Experiment manually for your site to see what form of nmblookup command works.

$Conf{FixedIPNetBiosNameCheck} = 0;
For fixed IP address hosts, BackupPC_dump can also verify the netbios name to ensure it matches the host name. An error is generated if they do not match. Typically this flag is off. But if you are going to transition a bunch of machines from fixed host addresses to DHCP, setting this flag is a great way to verify that the machines have their netbios name set correctly before turning on DCHP.

$Conf{PingPath} = '/bin/ping';
Full path to the ping command. Security caution: normal users should not be allowed to write to this file or directory.

If you want to disable ping checking, set this to some program that exits with 0 status, eg:

    $Conf{PingPath} = '/bin/echo';

$Conf{PingCmd} = '$pingPath -c 1 $host';
Ping command. The following variables are substituted at run-time:
  $pingPath      path to ping ($Conf{PingPath})
  $host          host name

Wade Brown reports that on solaris 2.6 and 2.7 ping -s returns the wrong exit status (0 even on failure). Replace with ``ping $host 1'', which gets the correct exit status but we don't get the round-trip time.

$Conf{CompressLevel} = 0;
Compression level to use on files. 0 means no compression. Compression levels can be from 1 (least cpu time, slightly worse compression) to 9 (most cpu time, slightly better compression). The recommended value is 3. Changing to 5, for example, will take maybe 20% more cpu time and will get another 2-3% additional compression. See the zlib documentation for more information about compression levels.

Changing compression on or off after backups have already been done will require both compressed and uncompressed pool files to be stored. This will increase the pool storage requirements, at least until all the old backups expire and are deleted.

It is ok to change the compression value (from one non-zero value to another non-zero value) after dumps are already done. Since BackupPC matches pool files by comparing the uncompressed versions, it will still correctly match new incoming files against existing pool files. The new compression level will take effect only for new files that are newly compressed and added to the pool.

If compression was off and you are enabling compression for the first time you can use the BackupPC_compressPool utility to compress the pool. This avoids having the pool grow to accommodate both compressed and uncompressed backups. See the documentation for more information.

Note: compression needs the Compress::Zlib perl library. If the Compress::Zlib library can't be found then $Conf{CompressLevel} is forced to 0 (compression off).

$Conf{PingMaxMsec} = 20;
Maximum round-trip ping time in milliseconds. This threshold is set to avoid backing up PCs that are remotely connected through WAN or dialup connections. The output from ping -s (assuming it is supported on your system) is used to check the round-trip packet time. On your local LAN round-trip times should be much less than 20msec. On most WAN or dialup connections the round-trip time will be typically more than 20msec. Tune if necessary.

$Conf{ClientTimeout} = 7200;
Timeout in seconds when listening for the transport program's (smbclient, tar etc) stdout. If no output is received during this time, then it is assumed that something has wedged during a backup, and the backup is terminated.

Note that stdout buffering combined with huge files being backed up could cause longish delays in the output from smbclient that BackupPC_dump sees, so in rare cases you might want to increase this value.

Despite the name, this parameter sets the timeout for all transport methods (tar, smb etc).

$Conf{MaxOldPerPCLogFiles} = 12;
Maximum number of log files we keep around in each PC's directory (ie: pc/$host). These files are aged monthly. A setting of 12 means there will be at most the files LOG, LOG.0, LOG.1, ... LOG.11 in the pc/$host directory (ie: about a years worth). (Except this month's LOG, these files will have a .z extension if compression is on).

If you decrease this number after BackupPC has been running for a while you will have to manually remove the older log files.

$Conf{DumpPreUserCmd} = undef;
$Conf{DumpPostUserCmd} = undef;
$Conf{RestorePreUserCmd} = undef;
$Conf{RestorePostUserCmd} = undef;
Optional commands to run before and after dumps and restores. Stdout from these commands will be written to the Xfer (or Restore) log file. One example of using these commands would be to shut down and restart a database server, or to dump a database to files for backup. Example:
   $Conf{DumpPreUserCmd} = '$sshPath -l root $host /usr/bin/dumpMysql';

The following variable substitutions are made at run time for $Conf{DumpPreUserCmd} and $Conf{DumpPostUserCmd}:

       $type         type of dump (incr or full)
       $xferOK       1 if the dump succeeded, 0 if it didn't
       $client       client name being backed up
       $host         host name (could be different from client name if
                                $Conf{ClientNameAlias} is set)
       $hostIP       IP address of host
       $user         user name from the hosts file
       $moreUsers    list of additional users from the hosts file
       $share        the first share name
       $shares       list of all the share names
       $XferMethod   value of $Conf{XferMethod} (eg: tar, rsync, smb)
       $sshPath      value of $Conf{SshPath},

The following variable substitutions are made at run time for $Conf{RestorePreUserCmd} and $Conf{RestorePostUserCmd}:

       $client       client name being backed up
       $xferOK       1 if the restore succeeded, 0 if it didn't
       $host         host name (could be different from client name if
                                $Conf{ClientNameAlias} is set)
       $hostIP       IP address of host
       $user         user name from the hosts file
       $moreUsers    list of additional users from the hosts file
       $share        the first share name
       $XferMethod   value of $Conf{XferMethod} (eg: tar, rsync, smb)
       $sshPath      value of $Conf{SshPath},
       $type         set to "restore"
       $bkupSrcHost  host name of the restore source
       $bkupSrcShare share name of the restore source
       $bkupSrcNum   backup number of the restore source
       $pathHdrSrc   common starting path of restore source
       $pathHdrDest  common starting path of destination
       $fileList     list of files being restored

$Conf{ClientNameAlias} = undef;
Override the client's host name. This allows multiple clients to all refer to the same physical host. This should only be set in the per-PC config file and is only used by BackupPC at the last moment prior to generating the command used to backup that machine (ie: the value of $Conf{ClientNameAlias} is invisible everywhere else in BackupPC). The setting can be a host name or IP address, eg:
        $Conf{ClientNameAlias} = 'realHostName';
        $Conf{ClientNameAlias} = '192.1.1.15';

will cause the relevant smb/tar/rsync backup/restore commands to be directed to realHostName, not the client name.

Note: this setting doesn't work for hosts with DHCP set to 1.

$Conf{PerlModuleLoad} = undef;
Advanced option for asking BackupPC to load additional perl modules. Can be a list (array ref) of module names to load at startup.

Email reminders, status and messages

$Conf{SendmailPath} = '/usr/sbin/sendmail';
Full path to the sendmail command. Security caution: normal users should not allowed to write to this file or directory.

$Conf{EMailNotifyMinDays} = 2.5;
Minimum period between consecutive emails to a single user. This tries to keep annoying email to users to a reasonable level. Email checks are done nightly, so this number is effectively rounded up (ie: 2.5 means a user will never receive email more than once every 3 days).

$Conf{EMailFromUserName} = '';
Name to use as the ``from'' name for email. Depending upon your mail handler this is either a plain name (eg: ``admin'') or a fully-qualified name (eg: ``admin@mydomain.com'').

$Conf{EMailAdminUserName} = '';
Destination address to an administrative user who will receive a nightly email with warnings and errors. If there are no warnings or errors then no email will be sent. Depending upon your mail handler this is either a plain name (eg: ``admin'') or a fully-qualified name (eg: ``admin@mydomain.com'').

$Conf{EMailUserDestDomain} = '';
Destination domain name for email sent to users. By default this is empty, meaning email is sent to plain, unqualified addresses. Otherwise, set it to the destintation domain, eg:
   $Cong{EMailUserDestDomain} = '@mydomain.com';

With this setting user email will be set to 'user@mydomain.com'.

$Conf{EMailNoBackupEverSubj} = undef;
$Conf{EMailNoBackupEverMesg} = undef;
This subject and message is sent to a user if their PC has never been backed up.

These values are language-dependent. The default versions can be found in the language file (eg: lib/BackupPC/Lang/en.pm). If you need to change the message, copy it here and edit it, eg:

  $Conf{EMailNoBackupEverMesg} = <<'EOF';
  To: $user$domain
  cc:
  Subject: $subj
  Dear $userName,
  This is a site-specific email message.
  EOF

$Conf{EMailNotifyOldBackupDays} = 7.0;
How old the most recent backup has to be before notifying user. When there have been no backups in this number of days the user is sent an email.

$Conf{EMailNoBackupRecentSubj} = undef;
$Conf{EMailNoBackupRecentMesg} = undef;
This subject and message is sent to a user if their PC has not recently been backed up (ie: more than $Conf{EMailNotifyOldBackupDays} days ago).

These values are language-dependent. The default versions can be found in the language file (eg: lib/BackupPC/Lang/en.pm). If you need to change the message, copy it here and edit it, eg:

  $Conf{EMailNoBackupRecentMesg} = <<'EOF';
  To: $user$domain
  cc:
  Subject: $subj
  Dear $userName,
  This is a site-specific email message.
  EOF

$Conf{EMailNotifyOldOutlookDays} = 5.0;
How old the most recent backup of Outlook files has to be before notifying user.

$Conf{EMailOutlookBackupSubj} = undef;
$Conf{EMailOutlookBackupMesg} = undef;
This subject and message is sent to a user if their Outlook files have not recently been backed up (ie: more than $Conf{EMailNotifyOldOutlookDays} days ago).

These values are language-dependent. The default versions can be found in the language file (eg: lib/BackupPC/Lang/en.pm). If you need to change the message, copy it here and edit it, eg:

  $Conf{EMailOutlookBackupMesg} = <<'EOF';
  To: $user$domain
  cc:
  Subject: $subj
  Dear $userName,
  This is a site-specific email message.
  EOF

CGI user interface configuration settings

$Conf{CgiAdminUserGroup} = '';
$Conf{CgiAdminUsers} = '';
Normal users can only access information specific to their host. They can start/stop/browse/restore backups.

Administrative users have full access to all hosts, plus overall status and log information.

The administrative users are the union of the unix/linux group $Conf{CgiAdminUserGroup} and the manual list of users, separated by spaces, in $Conf{CgiAdminUsers}. If you don't want a group or manual list of users set the corresponding configuration setting to undef or an empty string.

If you want every user to have admin privileges (careful!), set $Conf{CgiAdminUsers} = '*'.

Examples:

   $Conf{CgiAdminUserGroup} = 'admin';
   $Conf{CgiAdminUsers}     = 'craig celia';
   --> administrative users are the union of group admin, plus
     craig and celia.
   $Conf{CgiAdminUserGroup} = '';
   $Conf{CgiAdminUsers}     = 'craig celia';
   --> administrative users are only craig and celia'.

$Conf{CgiURL} = undef;
URL of the BackupPC_Admin CGI script. Used for email messages.

$Conf{Language} = 'en';
Language to use. See lib/BackupPC/Lang for the list of supported languages, which include English (en), French (fr), Spanish (es), and German (de).

Currently the Language setting applies to the CGI interface and email messages sent to users. Log files and other text is still in English.

$Conf{CgiUserHomePageCheck} = '';
$Conf{CgiUserUrlCreate} = 'mailto:%s';
User names that are rendered by the CGI interface can be turned into links into their home page or other information about the user. To set this up you need to create two sprintf() strings, that each contain a single '%s' that will be replaced by the user name. The default is a mailto: link.

$Conf{CgiUserHomePageCheck} should be an absolute file path that is used to check (via ``-f'') that the user has a valid home page. Set this to undef or an empty string to turn off this check.

$Conf{CgiUserUrlCreate} should be a full URL that points to the user's home page. Set this to undef or an empty string to turn off generation of URLs for user names.

Example:

   $Conf{CgiUserHomePageCheck} = '/var/www/html/users/%s.html';
   $Conf{CgiUserUrlCreate}     = 'http://myhost/users/%s.html';
   --> if /var/www/html/users/craig.html exists, then 'craig' will
     be rendered as a link to http://myhost/users/craig.html.

$Conf{CgiDateFormatMMDD} = 1;
Date display format for CGI interface. True for US-style dates (MM/DD) and zero for international dates (DD/MM).

$Conf{CgiNavBarAdminAllHosts} = 0;
If set, the complete list of hosts appears in the left navigation bar for administrators. Otherwise, just the hosts for which the user is listed in the host file (as either the user or in moreUsers) are displayed.

$Conf{CgiHeaderFontType} = 'arial';
$Conf{CgiHeaderFontSize} = '3';
Header font and size for CGI interface

$Conf{CgiNavBarBgColor} = '#ddeeee';
$Conf{CgiHeaderBgColor} = '#99cc33';
$Conf{CgiBodyBgColor} = '#ffffff';
Color scheme for CGI interface. Default values give a very light blue for the background navigation color, green for the header background, and white for the body background. (You call tell I should stick to programming and not graphical design.)

$Conf{CgiStatusHilightColor} = { ...
Hilight colors based on status that are used in the PC summary page.

$Conf{CgiHeaders} = '<meta http-equiv=``pragma'' content=``no-cache''>';
Additional CGI header text.

$Conf{CgiImageDir} = '';
Directory where images are stored. This directory should be below Apache's DocumentRoot. This value isn't used by BackupPC but is used by configure.pl when you upgrade BackupPC.

Example:

    $Conf{CgiImageDir} = '/usr/local/apache/htdocs/BackupPC';

$Conf{CgiExt2ContentType} = { };
Additional mappings of file name extenions to Content-Type for individual file restore. See $Ext2ContentType in BackupPC_Admin for the default setting. You can add additional settings here, or override any default settings. Example:
    $Conf{CgiExt2ContentType} = {
                'pl'  => 'text/plain',
         };

$Conf{CgiImageDirURL} = '';
URL (without the leading http://host) for BackupPC's image directory. The CGI script uses this value to serve up image files.

Example:

    $Conf{CgiImageDirURL} = '/BackupPC';

Back to Top


Version Numbers

Starting with v1.4.0 BackupPC switched to a X.Y.Z version numbering system, instead of X.0Y. The first digit is for major new releases, the middle digit is for significant feature releases and improvements (most of the releases have been in this category), and the last digit is for bug fixes. You should think of the old 1.00, 1.01, 1.02 and 1.03 as 1.0.0, 1.1.0, 1.2.0 and 1.3.0.

Back to Top


Author

Craig Barratt <cbarratt@users.sourceforge.net>

See http://backuppc.sourceforge.net.

Back to Top


Copyright

Copyright (C) 2001-2003 Craig Barratt

Back to Top


Credits

Xavier Nicollet, with additions from Guillaume Filion, added the internationalization (i18n) support to the CGI interface for v2.0.0. Xavier provided the French translation fr.pm, with additions from Guillaume.

Ryan Kucera contributed the directory navigation code and images for v1.5.0. He also contributed the first skeleton of BackupPC_restore.

Guillaume Filion wrote BackupPC_zipCreate and added the CGI support for zip download, in addition to some CGI cleanup, for v1.5.0.

Javier Gonzalez provided the Spanish translation, es.pm.

Manfred Herrmann provided the German translation, de.pm.

Many people have reported bugs, made useful suggestions and helped with testing; see the ChangeLog and the mail lists.

Your name could appear here in the next version!

Back to Top


License

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License in the LICENSE file along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.

Back to Top

 BackupPC