Tutorials How to get started with BackupPC on Ubuntu

How to get started with BackupPC on Ubuntu

contributor

BackupPC is a highly efficient backup system that requires no installations on the hosts to be backed up making it very easy to orchestrate. It features global deduplication, which allows you to store enormous amounts of backups in a small space. Deduplication is used during transfer, making it very good for backups over the internet. It also features compression, further minimizing storage usage.

This tutorial describes how to install and orchestrate BackupPC 4 on an UpCloud cloud server using Ubuntu or Debian operating system.

Deploying BackupPC cloud server

BackupPC will run on all available server plans, so you can start with a small one and simply upgrade to accommodate more clients to back up as your needs increase.

As a rule of thumb, 1 core per concurrent backup is plenty. A single full client backup takes anything between a few seconds and a few hours to complete.

For memory, just go with the fixed plans according to your CPU needs.

For storage, this tutorial will optimize cost and performance by splitting the data on the instance and HDD storage. This approach will place the ‘pc’ folder (somewhat equivalent of a database) on the instance root and the ‘cpool’ folder (akin to object storage) on separate storage. If the instance storage is sufficient as is, you can simply ignore adding it, the script below will adapt automatically.

Then for the operating system, choose Ubuntu 18.04 LTS or Debian GNU/Linux 10.

Storage setup for BackupPC cloud server

Once all set, click the Deploy button at the bottom of the page.

The deployment will only take a moment, after which you’ll receive the root password via your chosen delivery method, email by default. With the server deployed and password at hand, you can continue with the BackupPC installation.

Installing BackupPC

The installation is based on this BackupPC Wiki page. It is completely automated and will make use of additional storage if available on the instance.

Once the server is has been created, connect to your cloud server using SSH. Include the following additional parameter to bind the localhost:80 on the BackupPC cloud server to your local 8888 port:

ssh -L 8888:localhost:80 [email protected]<your-server-ip>

When logged in, first, set up the storage with this handy script below:

echo "if [[ -e /dev/vdb ]]; then mkfs.ext4 /dev/vdb; mkdir -p /srv/backuppc/cpool; echo '/dev/vdb /srv/backuppc/cpool ext4 defaults 0 0' >> /etc/fstab; mount -a; fi" | bash

Then, download and run the installation script with the following command:

wget -q -O - https://gitlab.molnix.com/molnix-open-source/backuppc-ubuntu-installer/-/raw/master/backuppc-ubuntu-installer | bash

The installation process might take a little while but once done, you should see an output like below.

Ok, it looks like we are finished.  There are several more things you
will need to do:

  - Browse through the config file, /etc/BackupPC/config.pl,
    and make sure all the settings are correct.  In particular,
    you will need to set $Conf{CgiAdminUsers} so you have
    administration privileges in the CGI interface.

  - Edit the list of hosts to backup in /etc/BackupPC/hosts.

  - Read the documentation in /usr/local/BackupPC/doc/BackupPC.html.
    Please pay special attention to the security section.

  - Verify that the CGI script BackupPC_Admin runs correctly.  You might
    need to change the permissions or group ownership of BackupPC_Admin.
    If this is an upgrade and you are using mod_perl, you will need
    to restart Apache.  Otherwise it will have stale code.

  - BackupPC should be ready to start.  Don't forget to run it
    as user backuppc!  The installation also contains
    a systemd/backuppc.service script that can be installed so
    that BackupPC can auto-start on boot.  This will also enable
    administrative users to start the server from the CGI interface.
    See systemd/README.

Enjoy!

With the BackupPC installed, you can get started setting up backups. To enable this, you’ll need the two following keys.

The password for backuppc username:

cat password

The public key needed to grant the BackupPC server access to the clients:

cat /var/lib/backuppc/.ssh/id_rsa.pub

With the require credentials available, continue in the next section on how to configure BackupPC.

Configuring BackupPC

BackupPC provides a convenient admin panel for easier backup management but it is configured to only grant access locally. The easiest way to connect to it is over an SSH tunnel. By using the SSH command as instructed in the previous section, you get to access the localhost of your cloud server from your web browser.

Open the BackupPC Web admin by going to http://localhost:8888/BackupPC_Admin

Log in using backuppc username and the password output by the cat password command above.

BackupPC admin panel

Then configure your BackupPC as needed.

At a minimum, you should enable rsync over SSH to back up clients efficiently. Go to the Xfer configuration in the Edit Config menu.

Edit Config -> Xfer – XferMethod: rsync.

Enable rsync by selecting it from the first drop-down menu.

Then click the Save button at the top to confirm the changes.

Enabling rsync config in BackupPC

That’s all! Your BackupPC server is now ready to start making backups. Continue below with how to add clients for backing up.

Adding clients

By using rsync to facilitate the backup, adding a client is as simple as adding them to the /etc/BackupPC/hosts list and including the BackupPC public SSH key. For each new client, you only need to do the following:

1) Copy the public SSH key to /root/.ssh/authorized_keys on the client:

ssh-copy-id -i /var/lib/backuppc/.ssh/id_rsa.pub [email protected]<client-hostname>

2) Add the client hostname on BackupPC server using the web UI or on the command line:

echo "<client-hostname> 0 backuppc" >> /etc/BackupPC/hosts

For example, to back up the server itself, run the following two commands:

ssh-copy-id -i /var/lib/backuppc/.ssh/id_rsa.pub [email protected]
echo "localhost 0 backuppc" >> /etc/BackupPC/hosts

In this case, both are executed on the server.

Taking and restoring backups

Once added, you’ll see the localhost appear on the list of hosts for backing up.

Taking backup with BackupPC

BackupPC will then manage the backups on the background without the need for user interaction.

If the first backup process doesn’t start automatically, try reloading the system configuration in the Admin Options.

Once the first full backup has completed, you can check the files in the backup by clicking the hostname and going to the Browse backups view.

Browsing backup files on BackupPC

Then if ever needed, you can selectively restore files as you want!

What next?

Since the instance only serves over SSH, you can set up a firewall to only allow access on port 22.

If you want to access the UI directly over the web, you should set up TLS, for example, using Let’s Encrypt on a reverse proxy or on the local Apache configuration.

For further support resources on BackupPC itself, check out the BackupPC wiki, BackupPC docs, as well as mailing lists. For example, a good practice is to set up the backup using a non-root account that has sudo rights. This is described in the docs.

2 thoughts on “How to get started with BackupPC on Ubuntu

    1. Hi Lauri, thanks for the question. BackupPC is great for creating file-level backups even of your own computer, while the UpCloud Backup feature is used to take snapshots of the whole system. BackupPC is not a replacement for the UpCloud Backup feature but rather works well as an addition for fine-grain control of your backups.

Leave a Reply

Your email address will not be published. Required fields are marked *

Locations

Helsinki (HQ)

In the capital city of Finland, you will find our headquarters, and our first data centre. This is where we handle most of our development and innovation.

London

London was our second office to open, and a important step in introducing UpCloud to the world. Here our amazing staff can help you with both sales and support, in addition to host tons of interesting meetups.

Singapore

Singapore was our 3rd office to be opened, and enjoys one of most engaged and fastest growing user bases we have ever seen.

Seattle

Seattle is our 4th and latest office to be opened, and our way to reach out across the pond to our many users in the Americas.