Table of Contents

HOWTO Install BackupPC

BackupPC is a high-performance, enterprise-grade system for backing up Linux and WinXX PCs and laptops to a server's disk. BackupPC is highly configurable and easy to install and maintain. It runs quite well on the DNS-323. The accompanying forum thread is located here.
For a Wikipedia description click here.

Requirements

Fun_Plug

You need to follow the directions here to get fun_plug working: http://www.inreto.de/dns323/fun-plug/0.5/

Fonz's fun_plug will set up perl, ssh, lighttpd, etc… I've highlighted the main bits.

Copy fun_plug and fun_plug.tgz to Volume 1 (using FTP) and reboot. 
If successful, the fun_plug.tgz file is unpacked (ffp directory)
and a telnet server is started.

Using rsync, you can download and install additional packages with:

  telnet <your hostname or IP address>
  cd /mnt/HD_a2
  rsync -av inreto.de::dns323/fun-plug/0.5/packages .
  rsync -av inreto.de::dns323/fun-plug/0.5/extra-packages/All/perl* .
  cd packages
  funpkg -i *.tgz

This should get all the required programs installed except for BackupPC

Create backuppc user

Create user and homedirectory

useradd -m backuppc

To not lose user by reboot - store password permanently

store-passwd.sh

Installing Extra Perl Modules

When I first made this page, I didn't remember having to do this step, but I've since set up another DNS-323 for someone else and I had to do this. So I think these steps are required. Let me know of the forum page if you find differently.

So let's install File::RsyncP and Compress::Zlib. Compress::Zlib isn't required and I haven't used it or tested it because my drives are large enough that I don't really need the compression. One of these days I'll test it out I'm sure.

The page for File::RsyncP is located here and here's the steps for installing:

cd /mnt/HD_a2/ffp/tmp/
wget http://search.cpan.org/CPAN/authors/id/C/CB/CBARRATT/File-RsyncP-0.68.tar.gz
tar zxvf File-RsyncP-0.68.tar.gz
cd File-RsyncP-0.68/
perl Makefile.PL
make
make test
make install

The same is done for Compress::Zlib located here, but you're going to have to install all of the prerequisites as well:

Compress::Raw::Zlib
IO::Compress::Base
IO::Compress::Base::Common
IO::Compress::Gzip
IO::Compress::Gzip::Constants
IO::Uncompress::Base
IO::Uncompress::Gunzip

I don't think this is difficult, just time consuming. However, if you're lazy and trust the perl automatic installer, you can run:

for N in Compress::Raw::Zlib IO::Compress::Base IO::Compress::Base::Common IO::Compress::Gzip IO::Compress::Gzip::Constants IO::Uncompress::Base IO::Uncompress::Gunzip
  do perl -MCPAN -e "install $N"
done

Compiling and Installing BackupPC

Download BackupPC (v3.1.0): http://sourceforge.net/project/showfiles.php?group_id=34854

cd /mnt/HD_a2/ffp/tmp
wget http://internap.dl.sourceforge.net/sourceforge/backuppc/BackupPC-3.1.0.tar.gz
tar zxvf BackupPC-3.1.0.tar.gz
cd BackupPC-3.1.0
perl configure.pl

Some of these questions will be different if you have a previous install. If you have a previous install and you're trying to complete redo everything, you need to remove you old /etc/BackupPC/config.pl file.

I didn't enable compression since 500 GB (on RAID 1) is well enough for me and I wasn't sure how well the DNS-323 would handle doing compression, but I suspect it would handle it well enough. Also, most of my files are jpeg images which aren't going to receive much benefit from compression. So enable it if you like and give us your results at the bottom!

Whatever is in the brackets [] is the default option and you can just press enter.

Go through the configure options

Full path to existing main config.pl []? Press enter 
Are these paths correct? [y]? y
BackupPC will run on host [...]? your HOSTNAME here (it's probably already the default answer)
BackupPC should run as user [backuppc]? 
Install directory (full path) [...]? /ffp/usr/BackupPC
Data directory (full path) []? /ffp/backuppcdata
Compression level [0]?
CGI bin directory (full path) []? /mnt/HD_a2/www/pages/cgi-bin
Apache image directory (full path) []? /mnt/HD_a2/www/pages/BackupPC
URL for image directory (omit http://host; starts with '/') []? /BackupPC

And it's now going to say:

Ok, we're about to:

  - install the binaries, lib and docs in /ffp/usr/BackupPC,
  - create the data directory /ffp/backuppcdata,
  - create/update the config.pl file /etc/BackupPC/config.pl,
  - optionally install the cgi-bin interface.
Do you want to continue? [y]? y

If you have no errors here (I got a PING error, but I don't think it's breaking anything) then BackupPC is installed, but we have to fix a couple of items. The location for the /etc (/etc/BackupPC/config.pl) will not work, so let's copy the /etc/BackupPC/ to the hard drive just make a symbolic link:

mv /etc/BackupPC/ /mnt/HD_a2/ffp/etc/
ln -s /mnt/HD_a2/ffp/etc/BackupPC /etc/

And let's put these two lines at the end of the fun_plug so that they run on startup

ln -s /mnt/HD_a2/ffp/etc/BackupPC /etc/
/mnt/HD_a2/ffp/usr/BackupPC/bin/BackupPC -d

Or without an editor in two easy lines:

echo "ln -s /mnt/HD_a2/ffp/etc/BackupPC /etc/" >> /mnt/HD_a2/fun_plug
echo "/mnt/HD_a2/ffp/usr/BackupPC/bin/BackupPC -d" >> /mnt/HD_a2/fun_plug

Another option is to create a startup script and put it in the /mnt/HD_a2/ffp/start/ directory

The script below works for me, if you use it you should of course NOT add the 2 lines mentioned above to the end of the fun_plug

#!/bin/sh

# PROVIDE: backuppc
# REQUIRE: DAEMON
# BEFORE:  LOGIN
# KEYWORD: shutdown

. /ffp/etc/ffp.subr

name="backuppc"
start_cmd="backuppc_start"
restart_cmd="backuppc_restart"
stop_cmd="backuppc_stop"
status_cmd="backuppc_status"

backuppc_start()
{
    ln -s /mnt/HD_a2/ffp/etc/BackupPC /etc/
    # If you run BackupPC under user root you don't need these commented lines,
    # otherwise you're smart enough to figure out why I have them in my config ;-)
    # ln -s /mnt/HD_a2/ffp/var/log/BackupPC /var/log/
    # su - backuppc -s /bin/sh -c '/mnt/HD_a2/ffp/usr/BackupPC/bin/BackupPC -d'
    /mnt/HD_a2/ffp/usr/BackupPC/bin/BackupPC -d
    echo "${name} started"
}

backuppc_restart()
{
    backuppc_stop
    sleep 1
    backuppc_start
}

backuppc_stop()
{
    /ffp/bin/pkill -f "/mnt/HD_a2/ffp/usr/BackupPC/bin/BackupPC -d"
    echo "${name} stopped"
}

backuppc_status()
{
    if [ "`ps ax | grep "BackupPC -d" | grep perl`" = "" ] ; then
        echo "${name} not running"
    else
        echo "${name} running"
    fi
}    


extra_commands="status"
run_rc_command "$1"

The last thing we need to do is fix the BackupPC_Admin cgi script to work with lighttpd. This change isn't exactly necessary if your web server is properly configured, but I found this to be simple enough:

cd /mnt/HD_a2/www/pages/cgi-bin
ln -s BackupPC_Admin BackupPC_Admin.pl

Next change the first line of this file (BackupPC_Admin) to:

#!/mnt/HD_a2/ffp/bin/perl

BackupPC is now installed and will run on startup, but it needs to be configured, and we need to fix lighttpd to run the BackupPC_Admin.pl perl file

Configuring Lighttpd

This section sets up Lighttpd to run perl scripts. It probably should be a separate wiki page (feel free to fix that yourself)

Copy the example lighttpd.conf file then edit it

cd /mnt/HD_a2/ffp/etc/
cp examples/lighttpd.conf .

Now edit lighttpd.conf

In the ”## modules to load” section uncomment the following line: “mod_cgi”, And make sure your config file has these settings:

server.document-root = "/mnt/HD_a2/www/pages/"
server.errorlog = "/mnt/HD_a2/www/logs/error.log"
accesslog.filename = "/mnt/HD_a2/www/logs/access.log"
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
server.port = 8080

Add the following lines:

$HTTP["url"] =~ "/cgi-bin/" {
    cgi.assign = ( ".pl" => "/mnt/HD_a2/ffp/bin/perl" )
}

after the commented out section:

#$HTTP["url"] =~ "\.pdf$" {

Make sure the log directory exists:

mkdir /mnt/HD_a2/www/logs

Lighttpd should be configured, now go ahead and start it:

sh /mnt/HD_a2/ffp/start/lighttpd.sh start

And set it to run on startup:

chmod a+x /mnt/HD_a2/ffp/start/lighttpd.sh

Your lighttpd should be good to go now.

You can test it by creating a file, /mnt/HD_a2/www/pages/cgi-bin/sample.pl, that contains:

#!/mnt/HD_a2/ffp/bin/perl
print "Content-Type: text/plain", "\n\n";
print "Hi there! This is a sample perl program!!!", "\n";

Open your browser and navigate to:

http://192.168.0.32:8080/cgi-bin/sample.pl

And you should only see (with no other text!):

Hi there! This is a sample perl program!!!

Configuring BackupPC

This section can be a bit daunting, but just read the documentation carefully

The main settings configuration file (/mnt/HD_a2/ffp/etc/BackupPC/config.pl) should be set correctly for the most part.

There are several methods for backup, but I'm doing windows machines and using rsyncd, so change this line the in config.pl file:

$Conf{XferMethod} = 'rsyncd';

Now you need to set up the config files for each host. First you need to create the directory that the config files will be stored in:

mkdir /mnt/HD_a2/ffp/etc/BackupPC/pc/

Now you are ready to create the config file. So, for a host with the name, computer1, you would edit the file /mnt/HD_a2/ffp/etc/BackupPC/pc/computer1.pl and put in:

$Conf{XferMethod} = 'rsyncd';
$Conf{RsyncShareName} = 'docs'; #this setting must match a later file
$Conf{RsyncdUserName} = 'SOMEUSERNAME'; #remember this username and password for a later file
$Conf{RsyncdPasswd} = 'SOMEPASSWORD';

# this line is optional but helps get rid of transfer errors in your log files while backing up 
# in addition to not backing up some unnecessary temp and cache files
$Conf{BackupFilesExclude} = [
 '*parent.lock',
 '*UsrClass.dat*',
 '*Firefox*Cache*',
 '*Local Settings/Temp*',
 'NTUSER.DAT',
 'ntuser.dat.LOG'
];

Now edit the file /mnt/HD_a2/ffp/etc/BackupPC/hosts and add to the bottom:

computer1  0  root

BackupPC should be ready to backup computer1, but we need to prepare computer1 with a client rsyncd

But now that you've edited the hosts file, you need to restart the BackupPC service:

killall BackupPC
/mnt/HD_a2/ffp/usr/BackupPC/bin/BackupPC -d

Configuring a Host for Backup

Download rsyncd (cygwin-rsyncd-2.6.8_0.zip) for Windows from the BackupPC website (hosted by SourceForge).

Unzip the files to c:\rsyncd

Edit the rsyncd.conf file and edit the docs section to your liking, such as:

[docs]
  path = c:/Documents and Settings
  comment = Documents and Settings
  strict modes = false
  auth users = USERNAME #this USERNAME comes from the computer1.pl file that we edited before
  secrets file = c:/rsyncd/rsyncd.secrets
  read only = true
  list = false

Now edit rsyncd.secrets and change UUU:PPP to the username and password that we entered above in the computer1.pl file:

USERNAME:PASSWORD

Edit the service.bat file (you may have to use wordpad, gvim, notepad++, etc… instead of regular notepad to deal with the line breaks)

You only need to edit this file if you need to remove the “rem ” from the last three lines to allow it to punch through the windows firewall

So after editing it, run service.bat

Web Admin

Alright, if everything has gone properly, you should be able to start backing up.

Access the web admin through:

http://192.168.0.32:8080/cgi-bin/BackupPC_Admin.pl

You should now see computer1 (or whatever your host-to-be-backed-up's name is) in the drop down

You should be able to “Start Full Backup” and not get any errors

My first full backup took 8.5 hrs for 53086 files that totaled 47 GB so that averages out to 1.54 MB/sec. Do keep in mind that the server is not transferring files the whole time, but is also doing other processes as well. Your average transfer speed will vary depending on the number of files you have, etc… For individual files the server was transferring at very high speeds (10+ MB/s over gigabit, sorry I don't have an exact number).

Anyway, subsequent backups (incremental backups) will not transfer as many files, but the server will still take awhile to rsync all of those files. So one incremental backup that transferred only 300 MB or so took 26 minutes.

Now you're ready to add more computers to be backed up to the server and edit your settings to your liking.

Troubleshooting

"unknown host" error when starting a backup

This can happen if you have added a host to conf/hosts but forgotten to reload the config file. Also, if you have a computer named computer1 and you can't do a ping computer1 and get a correct response (from the correct IP address), you may need to statically assign computer1's IP address (on computer1's machine) and then set up your /etc/hosts file give the IP address for computer1. So edit the /etc/hosts file to add:

192.168.xxx.xxx computer1 computer1

And to make this work on startup add to the end of your fun_plug file:

echo "192.168.xxx.xxx computer1 computer1" >> /etc/hosts

Edited by PetoZ 4.1.2010.

backup aborted (inet connect: Connection timed out)

Connection is blocked on firewall or rsyncd on client computer is not running.

restore failed (Unable to read 4 bytes)

To fix this change read only = false in c:/rsyncd/rsyncd.conf file on your client computer. I tested it and it works on Windows XP Home and Professional.