« HOWTO: Install and Configure sshHOWTO Enlarge A VMware Disk »

Backing Up and Restoring

30/07/08

Backing Up and Restoring

I use the rather wonderful bit of software called BackupPC to backup and restore my various PCs. The documentation is really very good and you should go read that rather than this mini-howto. :>

Hint:
This document is really for me so I can remember what I did to get it setup and working. I already have a working system that is backed up .

...

Installation

This is done with apt-get that way all the dependent Perl modules get installed too. Well almost par2 didn't :)

Installation
sudo apt-get install backuppc par2

During the installation you will be asked which web server to preconfigure BackupPC to use, I use Apache2 as it is already running on my backup machine.

Configuration

I then ran the configuration script to customise the installation. I have a very large disk array on the machine I'm using as my backup server. So I created a new LVM logical volume called backup. That is where the data from all the backups will live.

Creating my LVM logical group

sudo lvcreate -L 100G -nbackup vg1  


 
sudo mkfs.reiserfs /dev/vg1/backup 
 
sudo mkdir /backup 
sudo mount /dev/vg1/backup /backup 

I ended up using rsync transport, as the only windows I have are in the outside wall of my house. &#59;)

Edit the file /etc/backuppc/config.pl customising it for your needs. Stop the service before doing the edit and update.

sudo /etc/init.d/backuppc stop

As I have my backup data store on an LVM drive, /backup, I need to move the existing directory and create a symbolic link to join them back up.

sudo chown backuppc:backuppc /backup 


sudo chmod 750 /backup 
cd /var/lib 
sudo mv backuppc/* /backup 
sudo rmdir backuppc 
sudo ln -s /backup backuppc
sudo nano /etc/backuppc/config.pl

Change the Web access password, as I always forget to write down the generated one :oops:

cd /etc/backuppc 


sudo htpasswd ./htpasswd backuppc 

I like to change the hostname used for localhost to be the servers real name. You do that by editing the backuppc hosts file.

sudo nano /etc/backuppc/hosts

Restart the backuppc service.

sudo service backuppc start

Now check that the CGI interface is running, http://localhost/backuppc/index.cgi

To make the backup and restore more secure. We should remove the need for the backuppc user to ssh as root to all the client machines. To do this we create a shell script, it will be used for both backing up and restoring. We also need to allow access/permissions to sudo without a password for this command and nothing else.

Create the shell script BackupPC_rsync.sh

#!/bin/bash -f 


exec /usr/bin/rsync \$*

sudo chown backuppc:apache /etc/backuppc/BackupPC_rsync.sh 


sudo chmod 740 /etc/backuppc/BackupPC_rsync.sh

And now to make a few changesto the config.pl script.

sudo nano /etc/backuppc/config.pl

$Conf{BackupFilesOnly} = { 


  '/' => [ 'bin','boot', 'cdrom', 'data', 'dev', 'etc', 'home', 
    'initrd.img', 'initrd.img.old', 'lib', 'lib32', 'lib64', 
    'media', 'mnt', 'net', 'opt', 'proc', 'root', 'sbin', 'selinux',  
    'srv', 'sys', 'tmp','vmlinuz','vmlinuz.old' 
  ] 
};

$Conf{BackupFilesExclude} = { 


  '*' => [ 
    '.gvfs', 'backup', 'Cache', 'cache', 'tmp', 
    '*~', '*bak', '*log' 
  ] 
};

Server Side.

You should already have a user called backuppc that was created by the installation process. Set up ssh to work from the server machine so you can ssh to all the clients you wish to backup. See my mini-HOWTO on setting up ssh.

You will need to ssh from the server to each client at least once from the command line. This will setup the entry in the known hosts file.

Client Side

Create a new unprivileged user called backuppc

sudo groupadd -g 119 backuppc  


sudo useradd -g backuppc -u 126 backuppc -d /home/backuppc -m

Create a new shell script /etc/backuppc/BackupPC_rsync.sh

sudo mkdir /etc/backuppc
sudo nano /etc/backuppc/BackupPC_rsync.sh
/etc/backuppc/BackupPC_rsync.sh
#!/bin/bash -f
exec /usr/bin/rsync $*

and then set the permissions so it is owned by root and executable by the backuppc user

sudo chown backuppc:apache /etc/backuppc/BackupPC_rsync.sh
sudo chmod 740 /etc/backuppc/BackupPC_rsync.sh

and finally allow the user backuppc to run the command /etc/backuppc/BackupPC_rsync.sh as the user root without a password.

Edit the file /etc/sudoers and add the following line to the end

sudo visudo
backuppc ALL=NOPASSWD:    /etc/backuppc/BackupPC_rsync.sh

Comment out the option that requires a tty, this is on by default.

# Defaults    requiretty

From the server make sure you can ssh to the clients as the user backuppc without the need of a password.

You should now be able to backup and restore.


Pages: 1· 2· 3

No feedback yet

Here are a collection of Mini-HOWTOs some of which are too short even for that grand title. I keep them around as it is easier to remember where to look these up that to remember the content of the mini-HOWTO

Search

Contents

powered by b2evolution free blog software