Creating archives with BackupPC and 7zip

I have been paranoid about my data recently, and even though I have a fairly nice backup system at home, I really wanted to get my data off-site. I have a Dreamhost account, and therefore 50G of backup space and each additional G only cost .10 USD. Since I use a central BackupPC server at home to connect to my other servers and my and my wife’s laptops, I am able to leverage BackupPC’s archive feature to create archives of my latest backup sets. These archives are created using tar and b|gunzip2?. However, the archives that BackupPC creates are not protected in any way, and I do not want to store my files on Dreamhost’s servers without somehow password protecting them or encrypting them.

Enter 7zip. 7zip supports protecting archives with a password, and if we use a long (20+ characters) passphrase, the archives are as protected as can be. However, 7zip does not make a good backup utility for Linux because it does not preserve the file permissions, so we still need to create a tar archive prior to using 7zip to compress, and protect the archive.

You may be asking why we don’t simply use GPG or OpenSSL to encrypt the tar archive? We could, but we would still need to compress the archive, and 7zip does a better job than either gzip or bunzip2 does, so why not just kill two birds with one stone by protecting and compressing all in one fell swoop?

So, the goal is to create a BackupPC archive of a host first using tar to preserve the Linux file permissions of the files being archived, and then using 7zip to compress and protect the files. Easy as pie. Simply type the following:

su backuppc -c "/usr/share/backuppc/bin/BackupPC_tarCreate -t -h $HOST -n -1 -s \* . | 7z a -p\"$PASS\" -v$SPLT -si /home/archive/$HOST-$(date +%Y-%m-%d).tar.7z"

The above command assumes that the environment variables are set:

  • HOST – The name of the host you want to archive.
  • PASS – The password to use to protect the 7zip archive file.
  • SPLT – The number of blocks to split the archive volume on. This can be 1K, 2M, 3G, etc.

Assuming that the name of my host is ‘build’, and I specified a volume split of 3G, then the above command would produce the following compressed, protected, archive file: build-2008-12-23.tar.7z.001.


2 thoughts on “Creating archives with BackupPC and 7zip

  1. I’ve been looking for a similar solution for almost a year. Your solution seems good but unfortunately it is not working for me. Here’s the output error. Any idea?

    Compressing [Content] 0%

    System error:
    Too many open files in system

    I tried increasing the value of max open files using “uname -n 1024000” with no success :(

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s