« Birch Catkin Bug | Main | Bumblebee »
Sunday
Mar112012

Moving the BackupPC Data Directory to an external Hard Disk Drive

In Ubuntu 10.04 LTS the default install of BackupPC stores all the backups in the directory /var/lib/backuppc which is located on the main hard disk drive /dev/sda.  However, I wanted to store all my backups on an external USB hard disk drive /dev/sdb.  This post records what I had to do to get this to work.

Reformat the External Hard Disk

The external hard disk drive came with its disk preformatted as an NTFS file system. This file system does not support hard links which are critical for the efficient operation of BackupPC, so first we reformat the disk to EXT4 (a file system that does support hard links).

Display the partitions (I use parted rather than fdisk because its display is a bit clearer):

   sudo parted -l

Create an new /dev/sdb1 partition (here I use with fdisk because parted could not create EXT4 file systems):

  sudo fdisk /dev/sdb
     c (disable msdos mode)
     u (set units to sectors)
     d (delete partition 1)
     1
     n (create new primary partition 1)
     p
     1
     <Enter>Use default first and last sectors
     <Enter>
     w (Write out the new partition table)

Check the /dev/sdb1 partition exists (but the file system column is blank):

   sudo parted -l

Now we make the EXT4 files system:

   sudo mkfs -t EXT4 /dev/sdb1

Now check the partition is now EXT4:

   sudo parted -l

Install BackupPC

Now we actuall install BackupPC:

   sudo apt-get install backuppc

Set the password for account 'backuppc':

   sudo htpasswd /etc/backuppc/htpasswd backuppc

Point your web browser at http:/backuppc and log in as 'backuppc' with the password you have just set up. The BackupPC Server Status page should be displayed (it doesn't matter if there are some failed backups listed at the bottom of the page).

Copy the Data Directory Contents

Copy the BackupPC data directory contents to the external hard disk drive:

   sudo cp -r /var/lib/backuppc /media/usb0

And set its owner to 'backuppc':

   sudo chown -R backuppc:backuppc /media/usb0/backuppc

Check the new data directory is present and has the right permissions:

   sudo ls -al /media/usb0

And check its contents:

   sudo ls -al /media/usb0/backuppc

Set up a Symbolic Link from the Old Location to the New

Remove the old BackupPC data directory:

   sudo rm -r /var/lib/backuppc

And replace it with a symbolic link to the new data directory (note the order of the parameters is target path before link path):

   sudo ln -s /media/usb0/backuppc /var/lib/backuppc

Set the owner of the symbolic link to 'backuppc':

   sudo chown -h backuppc:backuppc /var/lib/backuppc

Check the symbolic link is present and has the right permissions:

   sudo ls -al /var/lib

And check that it links to the right contents:

   sudo ls -al /var/lib/backuppc

Restart the server (just to make sure everything reinitializes):

   sudo shutdown -r now

Point your web browser at http:/backuppc. The BackupPC Server Status page should be displayed. BackupPC is running with the data directory on the external hard disk drive.

Reader Comments (7)

Excellent post! this is what I was looking for.
2013-10-17 | Unregistered CommenterMartin
Great post!!! This is more easily with this method!
2013-11-04 | Unregistered Commenterkillahop
thanks for this

I really appreciate it

Mat
2014-01-27 | Unregistered Commentermat
Thank for sharing.
2014-02-04 | Unregistered CommenterCihan
Thank you. Great help for me :)
2014-02-16 | Unregistered Commenteralex
Hi,
i've just installed backuppc and migrated it to an external drive following your instructions. I've encountered a problem after rebooting. The backuppc login page displays and when user and password are entered I get an error message referring to a CG1 script being incorrect (or similar). If I enter http:/backuppc that takes me to the zamanda site.

Any help would be much appreciated
2014-03-18 | Unregistered CommenterRoy
Thank you very much
it work well for me :)
2014-06-25 | Unregistered Commenterzeid

PostPost a New Comment

Enter your information below to add a new comment.
Author Email (optional):
Author URL (optional):
Post:
 
All HTML will be escaped. Hyperlinks will be created for URLs automatically.