Table of Contents

BackupPC

This guide is written when installing BackupPC V4.4.0 which is included in the repository of Debian 11 Bullseye.

Server Setup

Installation

  1. Make a backup of /etc/BackupPC or /etc/backuppc, and /etc/apache2 if you install it over a previous BackupPC installation
  2. For a previous package install, uninstall with the packet manager first
  3. If you previously installed BackupPC from tarball, uninstall:
    1. dpkg –remove BackupPC
    2. search for all folders named BackupPC and manually remove them and their contents
  4. Install with apt install backuppc
  5. Install Apache Server through Proxy with user backuppc and group backuppc and enable the VirtualHost.
  6. Change the site access password
    htpasswd /etc/backuppc/htpasswd <user>
  7. Compare configuration entries of config.pl in /etc/backuppc/ or /etc/BackupPC/ and correct all file paths. The Debian packet manager install uses different folders to keep the installation files.

Setup encrypted LVM partition

Setup boot configuration

Maintenance

Host Setup

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.

Main Configuration on BackupPC server

Check whether a host is accessible

Configuration on Server for Localhost

Configuration on Server for local hosts

Configuration on Server for remote hosts

Configuration on Server for remote hosts accessible through relais

Configuration for Windows 10 running WSL1

  1. Windows 10: Install Windows Subsystem for Linux on Windows 10 hosts, which installs a Debian command line layer on top of your Windows 10 installation.
    WSL1 installs a bridged network connection which receives an IP address in the same subnet as Windows.
  2. Install ssh and rsync:
    sudo apt install ssh rsync
  3. Harden SSH and restart the service.
  4. Create user backuppc with a restricted shell, not able to do local but only remote logins (do not expire the user):
    sudo adduser --shell /bin/rbash --disabled-password backuppc
  5. Copy the Server's backuppc id_rsa.pub file to the Host's backuppc authorized_keys file. The authorized_keys file should contain further restrictions to prevent e.g. port forwarding, preceed the ssh-rsa string with 'restrict,from=“local.domain.subnet.ip”':
    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
  6. Allow user backuppc to run rsync as root, add the following line after %sudo:
    sudo visudo
    %sudo ALL=(ALL:ALL) ALL
    backuppc ALL=(root:root) NOPASSWD: /usr/bin/rsync
  7. If it's a new machine you are connecting make sure the public key of the host is added to the server and you have connected manually from server to host to add to the known_hosts file
    
    
  8. Test rsync access as root with the following command from user backuppc on the BackupPC Server:
    ssh <host> -p <port> sudo rsync --version
  9. For Windows: start the following program as a task after user login in Task Scheduler:
    C:\Users\<user>\AppData\Local\Microsoft\WindowsApps\bash.exe -c "sudo /etc/init.d/ssh start"

Configuration for Windows 11 running WSL2 or Hosts without fixed IP address

  1. Windows 11: Enable Windows Subsystem for Linux on Windows 11 hosts as Windows feature, then install Debian from the Microsoft store.
    WSL2 installs a NAT'ed network connection and assignes a new IP address on every reboot.
  2. Install ssh, autossh and rsync:
    sudo apt install ssh autossh rsync
  3. Harden SSH and restart the service.
  4. Create user backuppc with a restricted shell, not able to do local but only remote logins (do not expire the user):
    sudo adduser --shell /bin/rbash --disabled-password backuppc
  5. Copy the Server's backuppc id_rsa.pub file to the Host's backuppc authorized_keys file
  6. Allow user backuppc to run rsync as root, add the following line after %sudo:
    sudo visudo
    %sudo ALL=(ALL:ALL) ALL
    backuppc ALL=(root:root) NOPASSWD: /usr/bin/rsync
  7. Establish a ssh connection from host to server with reverse tunneling:
    autossh -M 0 -f -N -R <reverse_port>:localhost:<ssh_port> host.domain.tld -p <wan_port>

    Note: -M -f are autossh options, all others are ssh options; <reverse_port> is the port you will use to access the host from the server through the reverse ssh tunnel, <ssh_port> is the ssh port on the host, and <wan_port> is the ssh port on the server accessible from the wan.

    
    
  8. Use autossh instead of ssh to reestablish the ssh connection if it drops - add the following options in the server's sshd_config to have ssh drop the connection if unresponsive
    ClientAliveInterval 60
    ClientAliveCountMax 10
  9. If it's a new machine you are connecting make sure the public keys are exchanged on host and server and you have connected manually from each side to add both to the known_hosts file
    
    
  10. Test rsync access as root with the following command from user backuppc on the BackupPC Server:
    ssh localhost -p <reverse_port> sudo rsync --version
  11. For Windows: start the following programs as a task after user login in Task Scheduler (sleep 1 second is required to give autossh time to drop into background before the shell is terminated):
    C:\Users\<user>\AppData\Local\Microsoft\WindowsApps\bash.exe -c "sudo /etc/init.d/ssh start"
    C:\Users\<user>\AppData\Local\Microsoft\WindowsApps\bash.exe -c "autossh -M 0 -f -N -R <reverse_port>:localhost:<ssh_port> host.domain.tld -p <wan_port> && sleep 1"
  12. Note that these commands work if WSL was installed as Windows feature (e.g. WSL2, Windows 11) and Debian through the Microsoft Store, otherwise you need to find the location of bash.exe. In addition you need to allow <user> to execute /etc/init.d/ssh as root without password.
    
    
  13. The BackupPC host config file needs to backup localhost on port <reverse_port>.

Reverse Ports

Links

Configuration on Synology DSM6 Hosts

FIXME Rsync over ssh: "ERROR: module is read only" suddenly appeared

Special host configurations

Ping commands

Alternative setups for Windows hosts

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.

Remove files from backup