Tag Archives: Bacula

Network Backups Using BackupPC

BackupPC has been the only Ubuntu Server oriented backup method I have found to work great right after configuration and also have a web front-end for easy status monitoring/change configuration. I’m using it to backup my Linux *and* Windows machines on my local network – both full and incremental backups. There seem to be plenty that work nicely for Ubuntu Desktop but options for those with a graphical interface are limited on Ubuntu Server (as expected). One I tried previous to BackupPC was Bacula. I thought Bacula plus its web front-end Bweb would work nicely for my lab setup. However, even in the initial installation had issues communicating with MySQL and after numerous attempts to resolve the issue I decided to look at alternatives.

BackupPC, as mentioned, has a web front-end of which you can control almost every aspect of the backup setup/schedules. There is some initial configuration for network machines depending on the method of transfer, but it’s pretty simple to work through.

Here is the file browser on BackupPC’s web interface that shows a previous machine’s backup. This can be great if a user deletes a certain file on accident and needs to retrieve it a week later.

Rsync was the preferred method of setup for me as it allows for easy full backups as well as incremental. For my Windows machine I simply switched it to use smb as the transfer method, gave it the proper authentication, and it worked flawlessly. I can’t say I’ve had the best experience with Windows and Linux network file transfer permissions so this was delightful surprise.

Installation:

The box I set this up on was an Ubuntu Server running 10.04. Here is the setup and configuration guide to get BackupPC working with network machines:

First we need to install backuppc:

On Backup Server:

sudo apt-get install backuppc

Once it’s installed we can change the password from the auto-generated one:
sudo htpasswd /etc/backuppc/htpasswd backuppc

You should now be able to login to the Web administration interface by typing into a web browser:

http://yourip/backuppc/

You will be prompted for authentication where you will enter:

Username: backuppc
Password: Password you set in previous step.

Setting Up SSH Authentication For rsync:
Backuppc will use ssh to run the rsync command remotely to backup your machine. For this to work successfully you have to enable passwordless login for the user to the client machine. The steps below will allow you to successfully implement this:

On both machines:

Sudo nano /etc/hosts

Add each machine to the file so each will understand what each host corresponds with which IP address.

On Backup Server:

sudo su – backuppc

After entering in the password for backuppc you will be brought to a shell. This is designated simply by “$”.

Enter the following to generate your RSA key:

ssh-keygen -t rsa -C "backuppc"

On client machine:
We need to install rsync and setup the user and grant them permissions so that they may retrieve the files for backups.

sudo apt-get install rsync
sudo adduser backuppc
sudo -i
echo "backuppc  ALL=NOPASSWD: /usr/bin/rsync" >> /etc/sudoers
exit
sudo usermod –g admin backuppc

The usermod command places backuppc into the admin group. This may not be the most secure setup for you and it would be advisable to create a separate group to place the backuppc user into which has more limited permissions. However, for testing it will be nice to not have to deal with permissions issues so we will leave it in this group for now.

On Server:
While you are still logged in as the user backuppc:

ssh-copy-id backuppc@client

Make sure your client name is the actual name of the host and not the IP. Your authentication files will store these differently.

Passwordless SSH login should now work from the server to the client machine. Test it out using:

ssh backuppc@client

Setup a Full System Backup:
BackupPC’s interface isn’t amazing but it’s pretty simple to use. There are just a few steps to take to setup a full system backup for the designated client:

Login to the web interface.
Navigate to Edit Hosts.

Under the hosts tab you can add the client machine. Once again, make sure you input this as the actual hostname and not the IP. This will mess up your SSH passwordless login otherwise.

Save changes (button at the top) and then select the host under the drop down menu on the Top-Left.
Navigate to Edit Config

Under the Xfer tab we need to make a few changes:
XferMethod should be changed to “rsync”
Ensure the RsyncShareName has “/” next to the Insert button.
Change the two below to the following:

RsyncClientCmd: $sshPath -x -l backuppc $host $rsyncPath $argList+
RsyncClientRestoreCmd: $sshPath -x -l backuppc $host $rsyncPath $argList+

Notice that “$sshPath –q –x –l” has been has been changed to “$sshPath –x –l” removing the “-q” which enables quiet mode. We have removed it so we can examine any issues should they arise during the first backup. You can add “-q” back later.

The last changes you need to make is to add the folders you wish to exclude from the backup (if any). There are 2 ways to do this- chose the method you prefer.

You can add them in BackupFilesExclude or you can add them as additional arguments under RsyncArgs. Both give the same result.

Save the changes at the top and navigate to the host’s Home page. Under User Actions click Start Full Backup.

Your backup should now start for the client machine. You can check the status on the Status page. This will show you backup jobs currently running as well as those with errors. If there is an error there will be a link to the logfile. Since we disabled quiet mode on the SSH command you should have a good idea of what the issue is (if one should arise).

After the running backup disappears from the Running Jobs section, navigate to Host Summary and you should see the backup details, highlighted in Green.

It’s not too well documented, so it should be noted that the default location of your backups is /var/lib/backuppc

Conclusion:

This should give a good introduction of how to create backups using BackupPC and where things need to be configured. There are many more configuration options not covered here that you can look into on your own. I would recommend first looking through all of the options under the configuration for each host. You can click on each command to find out more information about what it means.

Overall the interface worked very well, and little terminal work was required besides the authentication setup listed above. I would like to see some RRD graph data added to include the speed of transfer and network congestion since I use the machine to backup multiple units. However, I’ll most likely just setup SNMP traps on another box and see if I can capture it’s network throughput alternatively using that method. Other than that, compression was great (up to 43% for a network filesystem backup) and the interface allowed for easy viewing when issues arise. For network administrators who want something powerful as an rsync or smb backup application vs. manual scripts and additions to cron, BackupPC is a great choice.

I have to give a lot of the credit for this article to this site. For the most part this got me through how to setup SSH passwordless transfers for BackupPC.