
Mastering Backups: A Comprehensive Guide to Setting Up BackupPC on Debian 10
In today’s data-driven world, a robust backup strategy isn’t just a good idea—it’s an absolute necessity. Whether you’re managing critical business servers or a personal home lab, data loss can be catastrophic. Fortunately, powerful open-source tools like BackupPC provide a reliable and cost-effective solution for safeguarding your information.
BackupPC is a high-performance, server-grade backup system that pulls data from client machines to a central server. Its standout feature is an ingenious pooling and deduplication scheme, which significantly reduces disk space requirements by storing identical files only once.
This guide will walk you through the complete process of installing, configuring, and securing BackupPC on a Debian 10 (Buster) server, empowering you to build a resilient and automated backup system.
Prerequisites
Before we begin, ensure you have the following:
- A server running a fresh installation of Debian 10.
- Root or
sudo
privileges on the server. - One or more client machines (Linux, Windows, or macOS) that you intend to back up.
Step 1: Installing BackupPC and Required Components
The first step is to install the BackupPC package along with the Apache web server, which is used to host its web-based management interface.
Open your server’s terminal and update your package lists:
sudo apt update
Next, install BackupPC and its dependencies:
sudo apt install backuppc apache2
During the installation, you may be prompted to configure Postfix for mail delivery. You can choose “Local only” if you don’t need external email notifications at this stage.
Step 2: Configuring the Apache Web Interface
By default, the BackupPC web interface is not enabled. We need to activate its Apache configuration and set up user authentication for security.
First, enable the BackupPC configuration module for Apache:
sudo a2enconf backuppc
Next, create a password file that will store the credentials for your web interface user. This command creates a new file and prompts you to set a password for a user named backuppcadmin
.
sudo htpasswd -c /etc/backuppc/htpasswd backuppcadmin
Security Tip: Always use a strong, unique password for your BackupPC administrative user to prevent unauthorized access to your backup management console.
Finally, restart the Apache service to apply the changes:
sudo systemctl restart apache2
You can now access the web interface by navigating to http://Your_Server_IP/backuppc
in your web browser. Log in with the username (backuppcadmin
) and password you just created.
Step 3: Initial BackupPC Server Configuration
BackupPC’s main configuration is stored in the /etc/backuppc/config.pl
file. While many defaults are sensible, we need to adjust a few key settings.
Open the configuration file with a text editor:
sudo nano /etc/backuppc/config.pl
Locate the following line, which defines the primary storage directory for all backups:
$Conf{TopDir} = '/var/lib/backuppc';
Ensure this directory is located on a partition with ample disk space to store your backups. You can change this path to a different mount point or disk if needed.
Next, find the $Conf{CgiAdminUsers}
setting and ensure the user you created (backuppcadmin
) is listed as an administrator:
$Conf{CgiAdminUsers} = 'backuppcadmin';
Save the file and exit the editor.
Step 4: Starting the BackupPC Service
With the initial configuration complete, it’s time to start the BackupPC service and enable it to launch automatically on boot.
sudo systemctl start backuppc
sudo systemctl enable backuppc
The service is now running as the dedicated backuppc
user, ready to start managing clients.
Step 5: Setting Up a Client for Backup
The real power of BackupPC comes from its ability to automatically back up remote machines. This process requires setting up passwordless SSH authentication so the BackupPC server can securely connect to its clients without manual intervention.
On the BackupPC Server:
Switch to the
backuppc
user:sudo -u backuppc -s
Generate a new SSH key pair. When prompted, press Enter to accept the default file location and leave the passphrase empty.
ssh-keygen -t rsa
Display the public key and copy its entire contents to your clipboard.
bash
cat /var/lib/backuppc/.ssh/id_rsa.pub
On the Client Machine:
- Log in to the client machine you want to back up.
- Create a dedicated user for backups (e.g.,
backup
). This is more secure than using root.
bash
sudo adduser backup
- Switch to the new user and create an
.ssh
directory.
bash
sudo -u backup -s
mkdir ~/.ssh
chmod 700 ~/.ssh
- Create the
authorized_keys
file and paste the public key from the server into it.
bash
nano ~/.ssh/authorized_keys
- Set the correct permissions for the file.
bash
chmod 600 ~/.ssh/authorized_keys
exit
To allow the backup
user to read all necessary files, you’ll also need to grant it permissions to run rsync
with root privileges. Edit the sudoers file securely:
sudo visudo
Add the following line at the end of the file:
backup ALL=NOPASSWD: /usr/bin/rsync
This ensures the backup
user can run rsync
via sudo
without a password prompt, which is essential for automated jobs.
Step 6: Adding the Client to the BackupPC Server
Now, we add the client to the server’s configuration so BackupPC knows what to back up.
On the BackupPC server, edit the hosts file:
sudo nano /etc/backuppc/hosts
Add an entry for your new client at the bottom of the file. The format is host dhcp user extra_config
.
# host dhcp user moreUsers # <---
client1.local 0 backup # Our new client
client1.local
: The hostname or IP address of the client machine.0
: Indicates the client does not use DHCP (use1
if it does).backup
: The username on the client machine that BackupPC will use to connect.
Save the file and restart the BackupPC service to apply the changes:
sudo systemctl restart backuppc
Step 7: Initiating Your First Backup
With everything configured, you can now trigger your first backup from the web interface.
- Navigate to
http://Your_Server_IP/backuppc
. - From the “Host” dropdown menu on the left, select your new client (
client1.local
). - Under the “User Actions” section, click “Start Full Backup.”
The status page will update, showing the backup job in progress. Once complete, you can browse the backed-up files, review logs, and even initiate file restores directly from the interface.
Congratulations! You now have a fully functional, automated, and disk-space-efficient backup system running on Debian 10. You can repeat the client setup process for every machine you need to protect, creating a centralized fortress for all your critical data.
Source: https://kifarunix.com/install-and-configure-backuppc-on-debian-10/