Wednesday, August 20, 2008

Installing backuppc in centos 5

I have been given the task of setting up one backuppc server, and below are the steps on how I did it :)

Server setup
  1. Download the backuppc 3.1.0 srpm from dev.centos.org
  2. Rebuild the srpm using rpmbuild. If the command is not there in your pc, install it first using 'yum install rpm-build'
    • # rpmbuild --rebuild backuppc-3.1.0-1.el5.centos.src.rpm
  3. Get your rpm file at /usr/src/redhat/RPMS/i386 and install it. Install all the perl module needed using yum
    • # yum install perl-Compress-Zlib perl-Archive-Zip perl-File-RsyncP perl-XML-RSS httpd
    • # rpm -Uvh backuppc-3.1.0-1%{dist}.i386.rpm
  4. User backuppc will be created upon installation. Change apache user to backuppc.
    • # vi /etc/httpd/conf/httpd.conf
    • Change 'User apache' to 'User backuppc'
    • Save
  5. Edit file /etc/httpd/conf.d/backuppc.conf
    • # vi /etc/httpd/conf.d/backuppc.conf
    • change 'Allow from 127.0.0.1' to 'Allow from all'
    • Save
  6. Create password for cgi-bin admin user
    • # htpasswd -c /var/lib/backuppc/passwd/htpasswd admin
  7. Edit backuppc config file
    • # vi /etc/BackupPC/config.pl
    • Find and change accordingly
      • $Conf{ServerHost} = 'localhost';
      • $Conf{SplitPath} = '/usr/bin/split';
        $Conf{CatPath} = '/bin/cat';
        $Conf{GzipPath} = '/bin/gzip';
        $Conf{Bzip2Path} = '/usr/bin/bzip2';
      • $Conf{BackupPCUser} = 'backuppc';
      • $Conf{TopDir} = '/var/lib/backuppc';
        $Conf{ConfDir} = '/etc/BackupPC';
        $Conf{LogDir} = '/var/log/BackupPC';
        $Conf{InstallDir} = '/usr';
        $Conf{CgiDir} = '/usr/share/backuppc/cgi-bin';
      • $Conf{ServerInitdPath} = '/etc/init.d/backuppc';
        $Conf{ServerInitdStartCmd} = '$sshPath -q -x -l root $serverHost$serverInitdPath start';
      • $Conf{SshPath} = '/usr/bin/ssh';
      • $Conf{NmbLookupPath} = '/usr/bin/nmblookup';
      • $Conf{PingPath} = '/bin/ping';
      • $Conf{CgiAdminUsers} = 'admin';
    • Save
  8. Grant passwordless sudo for user backuppc to run /bin/gtar and /bin/tar
    • # visudo
    • Add these entries
      • Defaults !lecture # to disable lecture
      • backuppc ALL=NOPASSWD:/bin/gtar,/bin/tar # enable user backuppc to run /bin/tar and /bin/gtar without authentication.
    • Comment this entry
      • #Defaults requiretty
    • Save
  9. Restart apache and backuppc service
    • # /etc/init.d/http restart
    • # /etc/init.d/backuppc restart
  10. Open your browser and point it to 'http://backuppc_server_ip/backuppc' and you should see the backuppc web interface
  11. After this, you have to do almost all the configuration through the web interface. To test, you can run localhost backup first. You have to create the host, fill up all the setting and you are ready to go. Record the host and ip in /etc/hosts.
Client setup
  1. Create new user
    • # useradd backupuser
    • # passwd backupuser
  2. Grant passwordless sudo for user backupuser
    • # visudo
    • Add these entries
      • Defaults !lecture # to disable lecture
      • backupuser ALL=NOPASSWD:/bin/gtar,/bin/tar # enable user backuppc to run /bin/tar and /bin/gtar without authentication.
    • Comment this entry
      • #Defaults requiretty
    • Save
  3. From the server using backuppc user, create ssh public key
    • # su -s /bin/bash backuppc
    • $ mkdir .ssh
    • $ chown backuppc.backuppc .ssh
    • $ chmod 700 .ssh
    • $ ssh-keygen -t rsa
    • $ ssh-copy-id -i .ssh/id_rsa.pub backupuser@client
  4. To make sure that the 3rd step is a success, try to ssh to backupuser@client using backuppc user from the server. If no password is asked, then you are ready.
    • # su -s /bin/bash backuppc
    • $ ssh backupuser@client
  5. You can start entering the client to the list of host and start backing up :)
Update: Precompiled rpm can be downloaded here

11 comments:

  1. an RPM is available at

    http://dev.centos.org/centos/5/testing/x86_64/RPMS/ (64bit)

    selinux must be configured or disabled to start using CGI on apache

    in CentOS 5.2, iptables must be manually configured to open port 80

    ReplyDelete
  2. this setup is great, but on Client setup #3 where it is telling you to create the keys I keep getting the error "Permission denied" to create the directory and the key. I am a noob and basically try to follow the instructions to the "T", what can I do to make this work?

    ReplyDelete
  3. Hi dennis,

    may i know what user u use when the error appeared?

    ReplyDelete
  4. I'm having one problem I can't seem to figure out. On Client Setup Setp three. On the server I enter
    # su -s /bin/bash backuppc
    $ mkdir .ssh

    This gives me the error;

    mkdir: cannot create directory '.ssh': Permission denied. I"m sure I've followed all of the steps correctly. Install is on Centos 5.1

    Thanks for the how-to. I've been struggling with this for two days under other directions.

    Dan

    ReplyDelete
  5. Hi Dan, check if the backuppc user's home directory exists and is owned by backuppc.

    If not, mkdir /home/backuppc && chown backuppc:backuppc /home/backuppc and then try it again.

    ReplyDelete
  6. Hello,

    after following the instructions (some tweaks needed), I configured BackupPC to do backups, using rsync, of linux host 192.168.121.131 and RsyncShareName /home/etienne/prog/perl/scripts. When I try running a backup, I get the error:

    =====================================
    Contents of file /var/lib/backuppc/pc/192.168.121.131/LOG.012009, modified 2009-01-21 16:45:31

    2009-01-21 16:45:22 full backup started for directory /home/etienne/prog/perl/scripts
    2009-01-21 16:45:26 Got fatal error during xfer (fileListReceive failed)
    2009-01-21 16:45:31 Backup aborted (fileListReceive failed)
    =======================================

    The XferLOG.bad file is
    =======================================
    Contents of file /var/lib/backuppc/pc/192.168.121.131/XferLOG.bad.z, modified 2009-01-21 16:45:31

    full backup started for directory /home/etienne/prog/perl/scripts
    Running: /usr/bin/ssh -q -x -l root 192.168.121.131 /usr/bin/rsync --server --sender --numeric-ids --perms --owner --group -D --links --hard-links --times --block-size=2048 --recursive --ignore-times . /home/etienne/prog/perl/scripts/
    Xfer PIDs are now 6572
    Got remote protocol 1651076184
    Fatal error (bad version): Xlib: connection to ":0.0" refused by server
    Xlib: No protocol specified


    Read EOF:
    Tried again: got 0 bytes
    fileListReceive() failed
    Done: 0 files, 0 bytes
    Got fatal error during xfer (fileListReceive failed)
    Backup aborted (fileListReceive failed)
    Not saving this as a partial backup since it has fewer files than the prior one (got 0 and 0 files versus 0)
    =======================================

    I would greatly appreciate any help out of this problem.

    Cheers,

    Etienne

    ReplyDelete
  7. I get problem from the begining. How to solve the below problem?

    [root@localhost ~]# yum install perl-Compress-Zlib perl-Archive-Zip perl-File-RsyncP perl-XML-RSS
    Loading "fastestmirror" plugin
    Loading mirror speeds from cached hostfile
    * base: ftp.isu.edu.tw
    * updates: ftp.oss.eznetsols.org
    * addons: ftp.isu.edu.tw
    * extras: ftp.isu.edu.tw
    base 100% |=========================| 1.1 kB 00:00
    updates 100% |=========================| 951 B 00:00
    addons 100% |=========================| 951 B 00:00
    extras 100% |=========================| 1.1 kB 00:00
    Setting up Install Process
    Parsing package install arguments
    Package perl-Compress-Zlib - 1.42-1.fc6.i386 is already installed.
    Package perl-Archive-Zip - 1.16-1.2.1.noarch is already installed.
    No package perl-File-RsyncP available.
    No package perl-XML-RSS available.
    Nothing to do

    ReplyDelete
  8. To install from Centos 5 testing:

    # yum install httpd mod_perl samba-client
    # cd /etc/yum.repos.d
    # wget http://dev.centos.org/centos/5/CentOS-Testing.repo
    # yum --enablerepo=c5-testing install backuppc
    # ln -s /usr/lib64/BackupPC /usr/lib/BackupPC # Fix a testing bug

    ReplyDelete
  9. Linker3000August 17, 2009

    Thanks for this. For Centos 5.3, change the 'yum install' in step 3 to also install the perl time modules:

    yum install perl-Compress-Zlib perl-Archive-Zip perl-File-RsyncP perl-XML-RSS httpd perl-Time-modules

    ReplyDelete
  10. [root@localhost bin]# service backuppc start
    Starting BackupPC: Can't locate BackupPC/Lib.pm in @INC (@INC contains: /usr/lib /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.7/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.6/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.5/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.7/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.6/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.5/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /usr/bin/BackupPC line 60.
    BEGIN failed--compilation aborted at /usr/bin/BackupPC line 60.
    [FAILED]
    I've followed it as mentioned above, but got stuck here..
    Pls look into it for me.

    ReplyDelete
  11. I followed your instructions to a T! However I got the message saying I could not connect to backuppc server. I had to disabled selinux to get the sucker working. I used the instructions on this website. I don't know how dangerous this is. But it doesn't matter as this box for me is behind a firewall. Thanks for taking the time to help us out.

    http://www.crypt.gen.nz/selinux/disable_selinux.html

    ReplyDelete