1. Introduction
BackupPC is an excellent enterprise level backup solution. I've been using BackupPC for a few months now and I decided to write an "How To" on installing and configuring BackupPC on CentOS 5 Linux.
2. Download the required perl packages
BackupPC requires the following perl packages. You can either download the rpm packages directly or use "yum" utility to install these directly.
perl-Archive-Zip perl-Compress-Zlib perl-File-RsyncP
3. Download the BackupPC software
You can download the BackupPC software from the BackupPC website at http://backuppc.sourceforge.net/. At the time of my install, the latest version was 3.0.0. so I downloaded BackupPC-3.0.0.tar.gz
4. Installing the required perl packages
You can use one of the following two methods to install the required perl packages. Method 1: Using yum to install the required perl packages:
yum install perl-Compress-Zlib yum install perl-Archive-Zip yum install perl-File-RsyncP
Method 2: Using rpm to install from the downloaded perl rpm packages:
rpm -ivh perl-Compress-Zlib-1.42-1.el4.centos.i386.rpm rpm -ivh perl-Archive-Zip-1.16-1.c4.noarch.rpm rpm -ivh perl-File-RsyncP-0.68-1.el4.centos.i386.rpm
Check to see if suidperl package is installed. If not, install it as well.
rpm -qa|grep suidperl output: perl-suidperl-5.8.5-36.RHEL4
5. Creating backuppc user
Create a user named "backuppc" with home directory as /usr1/backuppc.
useradd backuppc -d /usr1/backuppc passwd backuppc
Enter designed password the user "backuppc"
chmod -R 750 /usr1/backuppc chown -R backuppc:backuppc /usr1/backuppc
6. Installing BackupPC
Untar the downloaded BackupPC tar file to a location say /downloads and run the configure.pl script.
cd /downloads tar zxvf BackupPC-3.0.0.tar.gz cd /downloads/BackupPC-3.0.0 perl configure.pl
7. BackupPC Install session
Below I am including a sample BackupPC install session. Please note that the install script asks for user input. I highlighted the user input with bold text below. Sample BackupPC install session:
Is this a new installation or upgrade for BackupPC? If this is an upgrade please tell me the full path of the existing BackupPC configuration file (eg: /etc/BackupPC/config.pl). Otherwise, just hit return. --> Full path to existing main config.pl []?
Hit Return, as it's a new installation.
I found the following locations for these programs: bzip2 => /usr/bin/bzip2 cat => /bin/cat df => /bin/df gtar/tar => /bin/gtar gzip => /bin/gzip hostname => /bin/hostname nmblookup => /usr/bin/nmblookup par2 => perl => /usr/bin/perl ping => /bin/ping rsync => /usr/bin/rsync sendmail => /usr/sbin/sendmail smbclient => /usr/bin/smbclient split => /usr/bin/split ssh/ssh2 => /usr/bin/ssh --> Are these paths correct? [y]?
Hit Return
Please tell me the hostname of the machine that BackupPC will run on. --> BackupPC will run on host [server.domain.com]?
Hit Return if reported hostname is correct.
BackupPC should run as a dedicated user with limited privileges. You need to create a user. This user will need read/write permission on the main data directory and read/execute permission on the install directory (these directories will be setup shortly). The primary group for this user should also be chosen carefully. The data directories and files will have group read permission, so group members can access backup files. --> BackupPC should run as user [backuppc]?
Hit Return, as we are going to run BackupPC as user "backuppc"
Please specify an install directory for BackupPC. This is where the BackupPC scripts, library and documentation will be installed. --> Install directory (full path) [/usr/local/BackupPC]?
Hit Return, to accept the default location for the installation directory.
Please specify a data directory for BackupPC. This is where all the PC backup data is stored. This file system needs to be big enough to accommodate all the PCs you expect to backup (eg: at least several GB per machine). --> Data directory (full path) [/data/BackupPC]?
Enter /usr1/backuppc, as this is the home directory for the "backuppc" user.
BackupPC can compress pool files, providing around a 40% reduction in pool size (your mileage may vary). Specify the compression level (0 turns off compression, and 1 to 9 represent good/fastest to best/slowest). The recommended values are 0 (off) or 3 (reasonable compression and speed). Increasing the compression level to 5 will use around 20% more cpu time and give perhaps 2-3% more compression. --> Compression level [3]?
Hit Return, to accept the default compression level.
BackupPC has a powerful CGI perl interface that runs under Apache. A single executable needs to be installed in a cgi-bin directory. This executable needs to run as set-uid backuppc, or it can be run under mod_perl with Apache running as user backuppc. Leave this path empty if you don't want to install the CGI interface. --> CGI bin directory (full path) []?
Enter /var/www/cgi-bin/backuppc or the path to your cgi-bin directory.
BackupPC's CGI script needs to display various GIF images that should be stored where Apache can serve them. They should be placed somewher under Apache's DocumentRoot. BackupPC also needs to know the URL to access these images. Example: Apache image directory: /usr/local/apache/htdocs/BackupPC URL for image directory: /BackupPC The URL for the image directory should start with a slash. --> Apache image directory (full path) []?
Enter /var/www/html/backuppc or the path to your Apache DocumentRoot.
--> URL for image directory (omit http://host; starts with '/') []?
Enter /backuppc, as shown in the example.
Ok, we're about to: - install the binaries, lib and docs in /usr/local/BackupPC, - create the data directory /usr1/backuppc, - create/update the config.pl file /etc/BackupPC/config.pl, - optionally install the cgi-bin interface. --> Do you want to continue? [y]?
Hit Return, to finish the installation.
Created /usr/local/BackupPC/bin Created /usr/local/BackupPC/doc Created /usr/local/BackupPC/lib/BackupPC/CGI Created /usr/local/BackupPC/lib/BackupPC/Config Created /usr/local/BackupPC/lib/BackupPC/Lang Created /usr/local/BackupPC/lib/BackupPC/Storage Created /usr/local/BackupPC/lib/BackupPC/Xfer Created /usr/local/BackupPC/lib/BackupPC/Zip Created /var/www/html/backuppc Created /usr1/backuppc Created /usr1/backuppc/pool Created /usr1/backuppc/cpool Created /usr1/backuppc/pc Created /usr1/backuppc/trash Created /etc/BackupPC Created /var/log/BackupPC Installing binaries in /usr/local/BackupPC/bin Installing library in /usr/local/BackupPC/lib Installing images in /var/www/html/backuppc Making init.d scripts Installing docs in /usr/local/BackupPC/doc Installing config.pl and hosts in /etc/BackupPC PING server.example.com (127.0.0.1) 56(84) bytes of data. 64 bytes from server.example.com (127.0.0.1): icmp_seq=1 ttl=64 time=0.020 ms --- server.example.com ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.020/0.020/0.020/0.000 ms Installing cgi script BackupPC_Admin in /var/www/cgi-bin/backuppc 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 an init.d/backuppc script that can be copied to /etc/init.d so that BackupPC can auto-start on boot. This will also enable administrative users to start the server from the CGI interface. See init.d/README. Enjoy!
8. Creating startup scripts for backuppc
Copy the startup strict from the BackupPC install directory to /etc/init.d/
cp /downloads/BackupPC-3.0.0/init.d/linux-backuppc /etc/init.d/backuppc
Change the permissions on the copied script so it can be executed.
chmod 755 /etc/init.d/backuppc
Add backuppc to the list of services
chkconfig --add backuppc chkconfig backuppc on chkconfig --list|grep backuppc
9. Configuring BackupPC
Make a backup copy of the original BackupPC config.pl file.
cp /etc/BackupPC/config.pl /etc/BackupPC/config.pl.ORIG
Let's create a password to add in the BackupPC configuration file. Run "mkpasswd" utility (requires "expect" package to be installed).
mkpasswd -l 32 -d 16
Open /etc/BackupPC/config.pl, and copy the output of "mkpasswd" into the value for $Conf\{ServerMesgSecret\}. Exclude any directories from backup in /etc/BackupPC/config.pl
10. SSH setup for automatic login of backuppc user
Now we have configure SSH so that the user backuppc can login as root without password: Reference: http://backuppc.sourceforge.net/faq/ssh.html
ssh-keygen -t rsa (dont give a passphrase)
11. Changing permissions to access the BackupPC CGI web interface
cd /var/www/cgi-bin/backuppc chown backuppc:apache BackupPC_Admin chmod 750 BackupPC_Admin chmod u+s BackupPC_Admin
**Important Note:** Protect the cgi-bin/backuppc directory with .htaccess and .htpasswd
12. Start the backupp daemon
service backuppc start
No comments:
Post a Comment