This guide is written when installing BackupPC V4.3.2. It covers installation, migration of V3 backup data, and host setup. Since Debian 10 includes BackupPC V3.3, this guide covers installation from tarball rather than by using the packet manager. Find the BackupPC Documentation. I'm using the term host interchangeably with client to refer to the host to be backed up, and server to refer to the host (or server) where BackupPC is running on.
Debian 10 has BackupPC 3.3 in it's repositories. To install version 4 we need to manually install it.
apt update apt install wget ssh rsync hping3
#!/bin/bash set -e bpcver=4.3.2 bpcxsver=0.59 rsyncbpcver=3.1.2.1 # Needed only when installing apt-get update apt-get install -q -y apache2 apache2-utils libapache2-mod-perl2 glusterfs-client par2 perl smbclient rsync tar sendmail gcc zlib1g zlib1g-dev libapache2-mod-scgi rrdtool git make perl-doc libarchive-zip-perl libfile-listing-perl libxml-rss-perl libcgi-session-perl libacl1-dev echo -n "Give password or leave empty to generate one: " read -s PASSWORD echo if [[ $PASSWORD == "" ]]; then apt-get -qq -y install pwgen PASSWORD=`pwgen -s -1 32` echo "Generated password: $PASSWORD" else echo "Password given is: $PASSWORD" fi echo "$PASSWORD" > /root/password chmod 600 /root/password mkdir /srv/backuppc ln -s /srv/backuppc/ /var/lib/backuppc adduser --system --home /var/lib/backuppc --group --disabled-password --shell /bin/false backuppc echo "backuppc:$PASSWORD" | sudo chpasswd backuppc mkdir -p /var/lib/backuppc/.ssh chmod 700 /var/lib/backuppc/.ssh echo -e "BatchMode yes\nStrictHostKeyChecking no" > /var/lib/backuppc/.ssh/config ssh-keygen -q -t rsa -b 4096 -N '' -C "BackupPC key" -f /var/lib/backuppc/.ssh/id_rsa chmod 600 /var/lib/backuppc/.ssh/id_rsa chmod 644 /var/lib/backuppc/.ssh/id_rsa.pub chown -R backuppc:backuppc /var/lib/backuppc/.ssh # Fetch and install latest stable releases wget https://github.com/backuppc/backuppc-xs/releases/download/$bpcxsver/BackupPC-XS-$bpcxsver.tar.gz wget https://github.com/backuppc/rsync-bpc/releases/download/$rsyncbpcver/rsync-bpc-$rsyncbpcver.tar.gz wget https://github.com/backuppc/backuppc/releases/download/$bpcver/BackupPC-$bpcver.tar.gz tar -zxf BackupPC-XS-$bpcxsver.tar.gz tar -zxf rsync-bpc-$rsyncbpcver.tar.gz tar -zxf BackupPC-$bpcver.tar.gz cd BackupPC-XS-$bpcxsver perl Makefile.PL make make test make install cd ../rsync-bpc-$rsyncbpcver ./configure make make install cd ../BackupPC-$bpcver # When installing, use this ./configure.pl --batch --cgi-dir /var/www/cgi-bin/BackupPC --data-dir /var/lib/backuppc --hostname backuppc --html-dir /var/www/html/BackupPC --html-dir-url /BackupPC --install-dir /usr/local/BackupPC # When upgrading, use this instead: # ./configure.pl --batch --config-path /etc/BackupPC/config.pl # The following is good also when upgrading, unless you have modified the files yourself cp httpd/BackupPC.conf /etc/apache2/conf-available/backuppc.conf sed -i "/deny\ from\ all/d" /etc/apache2/conf-available/backuppc.conf sed -i "/deny\,allow/d" /etc/apache2/conf-available/backuppc.conf sed -i "/allow\ from/d" /etc/apache2/conf-available/backuppc.conf # Note that changing the apache user and group (next two commands) could cause other services # provided by apache to fail. There are alternatives if you don't want to change the apache # user: use SCGI or a setuid BackupPC_Admin script - see the docs. sed -i "s/export APACHE_RUN_USER=www-data/export APACHE_RUN_USER=backuppc/" /etc/apache2/envvars sed -i "s/export APACHE_RUN_GROUP=www-data/export APACHE_RUN_GROUP=backuppc/" /etc/apache2/envvars echo '<html><head><meta http-equiv="refresh" content="0; url=/BackupPC_Admin"></head></html>' > /var/www/html/index.html a2enconf backuppc a2enmod cgid service apache2 restart cp systemd/init.d/debian-backuppc /etc/init.d/backuppc chmod 755 /etc/init.d/backuppc update-rc.d backuppc defaults chmod u-s /var/www/cgi-bin/BackupPC/BackupPC_Admin touch /etc/BackupPC/BackupPC.users sed -i "s/$Conf{CgiAdminUserGroup}.*/$Conf{CgiAdminUserGroup} = 'backuppc';/" /etc/BackupPC/config.pl sed -i "s/$Conf{CgiAdminUsers}.*/$Conf{CgiAdminUsers} = 'backuppc';/" /etc/BackupPC/config.pl chown -R backuppc:backuppc /etc/BackupPC # Needed only when installing echo $PASSWORD | htpasswd -i /etc/BackupPC/BackupPC.users backuppc #service backuppc start
$Conf{PoolV3Enabled} = 1; $Conf{BlackoutPeriods} = []; $Conf{XferMethod} = 'rsync';
ln -s /backuppc /var/lib/backuppc
service backuppc start
htpasswd /etc/BackupPC/BackupPC.users <user>
sudo passwd <user>
To disable authentication, comment the auth instructions in /etc/backuppc/apache.conf and restart backuppc and apache.
RedirectMatch /backuppc /BackupPC_Admin
service backuppc stop
df -i df -h
/usr/local/BackupPC/bin/BackupPC_migrateV3toV4
service backuppc start
/usr/local/BackupPC/bin/BackupPC_nightly 0 255
du -csh /backuppc/cpool/?/?/?
cd /backuppc/pc find <machine> -xdev -type f -links +1 -printf "%i %n %p\n" > machine.txt
You can follow the steps in this paragraph to migrate an old V3 installation from an obsolete backuppc machine to a new V4 installation on a Debian 10 backuppc machine. You may need to omit steps if they do not apply to your situation.
You can omit this step if you are setting up a new data drive and still have access to the drive containing V3 data.
dd if=/dev/mapper/vg_backup-lv_backup of=/dev/sde1 bs=4M status=progress
kill -USR1 <pid>
mount /dev/sde1 /mnt/backup ln -s /mnt/backup/backuppc /var/lib/backuppc
chown -R backuppc:backuppc /mnt/backup
service backuppc stop service backuppc status
rsync -az -H --delete --numeric-ids --info=progress2 /path/to/source/ /path/to/dest/
ln -s /backuppc /var/lib/backuppc
service backuppc start
update-rc.d backuppc disable
/usr/local/BackupPC/bin/BackupPC_backupDelete -h host -n num
/backup
and new storage to /new-backup
rsync -axHAWXS --numeric-ids --info=progress2 /backup /new-backup
All hosts are setup with rsync through ssh. For Windows 10 hosts I use the Windows Subsystem for Linux which allows to setup a Debian layer to access the host. To backup the localhost we need a small tweak which is explained below.
$Conf{PoolV3Enabled} = 0; $Conf{BlackoutPeriods} = [{ hourBegin => 10, hourEnd => 3, weekDays => [0, 1, 2, 3, 4, 5, 6], }]; $Conf{XferMethod} = 'rsync';
$Conf{CgiNavBarLinks} = [ { link => "?action=view&type=docs\" target=\"blank", lname => "Documentation", } { link => "https://github.com/backuppc/backuppc/wiki\" target=\"blank", lname => "Wiki", } { link => "https://backuppc.github.io/backuppc\" target=\"blank", lname => "Homepage", } ];
perl -e 'print(gethostbyname("myhost") ? "ok\n" : "not found\n");'
nmblookup myhost
If this fails you will see output like:
name_query failed to find name myhost
If it is successful you will see output like:
local.domain.subnet.ip myhost<00>
nmblookup -B local.domain.subnet.255 myhost
If necessary, experiment with the nmblookup command which will return the IP address of the host given its name. Then update $Conf{NmbLookupFindHostCmd} with any necessary options to nmblookup.
ssh <host>
$Conf{RsyncClientPath} = '/usr/bin/rsync'; $Conf{RsyncSshArgs} = ['-e', '/usr/bin/sudo -p'];
$Conf{BackupFilesOnly} = ['/etc', '/root', '/home', '/usr', '/var', '/boot', '/sys'];
sudo apt install ssh rsync
sudo visudo %sudo ALL=(ALL:ALL) ALL backuppc ALL=(root:root) NOPASSWD: /usr/bin/rsync
$Conf{RsyncClientPath} = 'sudo /usr/bin/rsync'; $Conf{RsyncSshArgs} = ['-e', '$sshPath'];
$Conf{RsyncShareName} = ['/']; $Conf{BackupFilesExclude} = ['/proc', '*.vdi'];
$Conf{RsyncClientPath} = 'sudo /usr/bin/rsync'; $Conf{RsyncSshArgs} = ['-e', '$sshPath -p <port>']; $Conf{PingCmd} = '/usr/bin/sudo /usr/sbin/hping3 $host -p <port> -c 1 -S'; $Conf{PingMaxMsec} = 300; $Conf{ClientNameAlias} = 'subdomain.domain.tld';
$Conf{RsyncShareName} = ['/']; $Conf{BackupFilesExclude} = ['/proc', '*.vdi'];
apt update apt install hping3
$Conf{PingCmd} = '/bin/ssh -p <port> -o ConnectTimeout=2 $host echo "1 packets transmitted, 1 received, 0% packet loss, time 0ms"';
sudo apt install ssh rsync
sudo adduser --shell /bin/rbash --disabled-password backuppc
restrict,from="local.domain.subnet.ip" ssh-rsa <BASE64-PUBKEY-REPRESENTATION> backuppc
It should further be owned by root and being read- but not writable by the backuppc user, to prevent removal of SSH restrictions. In older SSH versions you must enter the following instead of restrict:
no-pty,no-port-forwarding,no-X11-forwarding,no-agent-forwarding,from="local.domain.subnet.ip" ssh-rsa <BASE64-PUBKEY-REPRESENTATION> backuppc
sudo visudo %sudo ALL=(ALL:ALL) ALL backuppc ALL=(root:root) NOPASSWD: /usr/bin/rsync
backuppc
on the BackupPC Server:ssh <new host> sudo rsync --version
cd /home/<user>/temp wget https://download.samba.org/pub/rsync/rsync-3.1.3.tar.gz tar xzvf rsync-3.1.3.tar.gz cd rsync-3.1.3 export CFLAGS=--static ./configure make
restrict,from="local.domain.subnet.ip" ssh-rsa <BASE64-PUBKEY-REPRESENTATION> backuppc
It should further be owned by root and being read- but not writable by the backuppc user, to prevent removal of SSH restrictions.
cd /etc/sudoers.d sudo vim # Allow backuppc backuppc ALL=(root:root) NOPASSWD: /var/services/homes/backuppc/bin/rsync
$Conf{RsyncShareName} = ['/', '/home'];
$Conf{RsyncShareName} = ['/', '/mnt/c', '/mnt/d']; $Conf{BackupFilesExclude} = [ '/proc', '*.vdi', 'Windows10Upgrade', 'System Volume Information', '$RECYCLE.BIN', '*.mkv', ];
documents
then add the line as shown below in the sample config file:$Conf{RsyncShareName} = ['/', '/volume1']; $Conf{BackupFilesExclude} = [ '/proc', '@eaDir', 'media', '*.mkv', '*.vdi', # exclude any shared folders here '@documents@', ];
$Conf{RsyncClientPath} = 'sudo /var/services/homes/backuppc/bin/rsync';
$ /bin/ping <host> -c 1
$ sudo /usr/sbin/hping3 <host> -p <port> -c 1 -S
$ ssh -p <port> -o ConnectTimeout=2 <host> echo "1 packets transmitted, 1 received, 0% packet loss, time 0ms"
$ /bin/echo
I'm not using any of the methods described in below links. I have collected those during my search for the best way to integrate Windows hosts into BackupPC. If you need to backup a host which does not run Windows 10, or does not provide the Microsoft Windows Subsystem for Linux, then those links might be helpful.