Install and set up BackupPC on CentOS 7

Before going deep with the instructions to install and setup this backup solution you could want to check how I prepare the storage to be used with BackupPC, in my case I choose RAID1 using two hard drives.

At this time I want to explain steps that I followed to install and set up BackupPC software on my server.

# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)

Installing BackupPC

Let’s start installing the proper CentOS package.

 # yum install BackupPC

In this first step I found a failure due to an unmet dependency, I could fix it with the following command:

 # package-cleanup --cleandupes

As a reader have commented if you add rpmforge and epel repositories you can prevent the previous problem, so let’s document how to add them:

RPMforge: repository is a utility that is used to install third party software packages under Red Hat Enterprise Linux (RHEL) and Community ENTerprise Operating System (CentOS). It provides more than 5000 software packages in the rpm format for these Linux distributions.

# wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm
 # rpm -Uvh rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm

Importing repository key:

# wget http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
# rpm --import RPM-GPG-KEY.dag.txt
# ls -lrt /etc/pki/rpm-gpg
...
-rw-r--r--  1 root root 1672 Apr 15  2011 RPM-GPG-KEY-rpmforge-dag
...

Installing packages from RPMforge:

 # yum --enablerepo=rpmforge install PACKAGE_NAME

EPEL (Extra Packages for Enterprise Linux) is open source and free community based repository project from Fedora team which provides 100% high quality add-on software packages for Linux distribution including RHEL (Red Hat Enterprise Linux), CentOS, and Scientific Linux. Epel project is not a part of RHEL/Cent OS but it is designed for major Linux distributions by providing lots of open source packages like networking, sys admin, programming, monitoring and so on.

# wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-6.noarch.rpm
 # rpm -ivh epel-release-7-6.noarch.rpm
 Preparing... ################################# [100%]
 Updating / installing...
 1:epel-release-7-6 ################################# [100%]

Checking if everything is fine:

# yum repolist
 ...
 Loading mirror speeds from cached hostfile
 * base: centos.mirror.xtratelecom.es
 * epel: epel.check-update.co.uk
 * extras: centos.mirror.xtratelecom.es
 * nux-dextop: mirror.li.nux.ro
 * rpmforge: fr2.rpmfind.net
 * updates: centos.mirror.xtratelecom.es
 ...

How to use:

 # yum --enablerepo=epel info PACKAGE_NAME

Configuring Apache

Now BackupPC package is fully installed it’s time to set up Apache web server, I prefer backup Apache config files:

# systemctl status httpd
 ● httpd.service - The Apache HTTP Server
 Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
 Active: inactive (dead)
 Docs: man:httpd(8)
 man:apachectl(8)
 # cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.`date +%Y%m%d`
 # cp /etc/httpd/conf.d/BackupPC.conf /etc/httpd/conf.d/BackupPC.conf.`date +%Y%m%d`
 # vim /etc/httpd/conf/httpd.conf
 ...
 User backuppc
 ...
 # /usr/sbin/httpd -v
 Server version: Apache/2.4.6 (CentOS)
 Server built: Nov 19 2015 21:43:13
 # vim /etc/httpd/conf.d/BackupPC.conf
 ...
 Require ip 10.111.1
 ...
 # /usr/sbin/apachectl configtest
 Syntax OK
 # systemctl enable httpd
 # systemctl is-enabled httpd
 enabled

Ensure that all BackupPC files are owned by backuppc owner and apache group:

# chown -R backuppc.apache /etc/BackupPC /etc/httpd/conf.d/BackupPC.conf /var/lib/BackupPC

As optional step I changed owner and group to the installation directory:

 # chown -R backuppc.backuppc /usr/share/BackupPC

Configure Backuppc Apache user password:

# htpasswd -c /etc/BackupPC/apache.users backuppc
 New password:
 Re-type new password:

Check access to Apache from remote host:

$ telnet g8-1 80
Trying xxx.xxx.x.xxx...
telnet: Unable to connect to remote host: No route to host

As the previous check points that the server firewall is blocking HTTP service, so let’s check if 80 port is opened on this server:

# firewall-cmd --zone=public --query-port=80/tcp
no

Open this port to be able to connect with Apache web server:

# firewall-cmd --permanent --zone=public --add-port=80/tcp
success
# firewall-cmd --reload
success
remoteHost$ telnet g8-1 80
Trying xxx.xxx.x.xxx...
Connected to g8-1.
Escape character is '^]'.

Configure BackupPC script

To see “Edit Hosts” and “Edit Config” navigation items is needed to change this configuration file /etc/backuppc/config.pl:

...
$Conf{CgiAdminUserGroup} = ‘backuppc’;
$Conf{CgiAdminUsers} = ‘backuppc’;
...
$Conf{PingPath} = '/bin/ping';

Configure CentOS user

Configure backuppc OS user:

# usermod -s /bin/bash backuppc
# passwd backuppc
# su - backuppc
$ cd && ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/var/lib/BackupPC/.ssh/id_rsa):
 Created directory '/var/lib/BackupPC/.ssh'.
 Enter passphrase (empty for no passphrase):
 Enter same passphrase again:
 Your identification has been saved in /var/lib/BackupPC/.ssh/id_rsa.
 Your public key has been saved in /var/lib/BackupPC/.ssh/id_rsa.pub.
 The key fingerprint is:
 18:7e:a2:7b:ae:56:a9:f2:55:6d:92:f4:60:65:ea:aa backuppc@g8.acme
 The key's randomart image is:
 +--[ RSA 2048]----+
 | o |
 | + |
 | . = |
 | . * = |
 | +.S + |
 | .o= o |
 | .oo |
 | . o+. |
 | +E+. |
 +-----------------+

Starting BackupPC services

With all these points the basic BackupPC configuration is done so let’s start the services:

# systemctl enable backuppc
 backuppc.service is not a native service, redirecting to /sbin/chkconfig.
 Executing /sbin/chkconfig backuppc on
# systemctl start backuppc
# systemctl start httpd

Testing our installation

Checking if it’s possible to get status information from the backuppc server using command line I face this problem:

# su - backuppc
-bash-4.2$ /usr/share/BackupPC/bin/BackupPC_serverMesg status info
Can't connect to server (unix connect: No such file or directory)

To fix previous problem is needed create the following directory:

# mkdir /var/run/BackupPC
# chown backuppc.backuppc /var/run/BackupPC
# systemctl restart backuppc

Checking again is observed that backup server is answering properly:

$ /usr/share/BackupPC/bin/BackupPC_serverMesg status info
Got reply: %Info = ("ConfigLTime" => "1457211930","DUlastValueTime" => "1457211930","ConfigModTime" => "1457211709","nextWakeup" => "1457215200","DUDailyMax" => 3,"DUDailyMaxTime" => "1457211930","Version" => "3.3.1","pid" => 5109,"DUlastValue" => 3,"HostsModTime" => "1426394632","startTime" => "1457211930");
BackupPC_Web

Fixing automatic service start when server boots

reader had commented that he had a problem when BackupPC service started and some actions needed to be done to fix the service start, this comment was related to this previous entry, if you get this message when the service is started, you could try the following fix, the first to do is to find the script which controls the service:

# systemctl status backuppc
● backuppc.service - SYSV: Starts and stops the BackupPC server
Loaded: loaded (/etc/rc.d/init.d/backuppc; static; vendor preset: disabled)
Active: active (running) since Sun 2016-05-29 21:26:39 CEST; 14min ago
Docs: man:systemd-sysv-generator(8)
Process: 3410 ExecStart=/etc/rc.d/init.d/backuppc start (code=exited, status=0/SUCCESS)

So let’s edit /etc/rc.d/init.d/backuppc script, and we have to add the bold line:

$ cd /etc/rc.d/init.d/
# cp backuppc backuppc.OLD.`date +%Y%m%d`
start() {...
echo -n "Starting BackupPC: "
[ ! -d /var/run/BackupPC ] && mkdir /var/run/BackupPC; chown backuppc.backuppc /var/run/BackupPC;
...

It’s time to restart the service and check its status:

# systemctl stop backuppc
# systemctl start backuppc
$ /usr/share/BackupPC/bin/BackupPC_serverMesg status info
Got reply: %Info = ("ConfigLTime" => "1464549999","poolFileCntRep" => 0,"cpoolFileCntRep" => 0,"DUDailyMaxReset" => 0,"cpoolFileCnt" => 0,"cpoolFileCntRm"...

At this point when server is restarted the service is not automatically up, let’s check if the service is enabled we get this:

# systemctl is-enabled backuppc
static

If you want a deeper explanation about what static services means take a look to this entry.

Let’s to change service descriptor and add [Install] section:

# cp /etc/systemd/system/backuppc.service /etc/systemd/system/backuppc.service.OLD.`date +%Y%m%d`
# vim /etc/systemd/system/backuppc.service
...
[Install]
WantedBy = multi-user.target

With this modification we try to enable the static unit:

# systemctl enable backuppc
Created symlink from /etc/systemd/system/multi-user.target.wants/backuppc.service to /etc/systemd/system/backuppc.service.

Other useful references would be:


“Whenever you find yourself on the side of the majority, it is time to pause and reflect.”
–Mark Twain

21 thoughts on “Install and set up BackupPC on CentOS 7

  1. Great set of instructions. Thank you! I have BackupPC working however, if I restart my server or lose power, BackupPC wont function until I re-enter the following commands:

    mkdir /var/run/BackupPC
    chown backuppc.backuppc /var/run/BackupPC
    systemctl restart backuppc

    After re-entering those commands, everything functions normally again. Is there a way to configure the system so that BackupPC will run automatically on startup?

    1. Thank you very much for your comment Paul. To start backuppc service on bootup you could try the following command:
      # systemctl enable backuppc

  2. if you add the repos rpmforge and epel to yum repos there will be no probs with dependencies 😉

  3. You don’t have permission to access /BackupPC on this server………………………..

    debido a que en /etc/httpd/conf.d/BackupPC.conf……………, está como Require local me daba error, pero al cambiar a Require all granted, funcionó, gracias…

  4. “Edit Hosts” and “Edit Config” navigation items are missing. (your screenshot is showing the same navigation with the missing items)

    Any ideas?

    1. Hello Travis,

      In my case I had to change some properties in this configuration file /etc/backuppc/config.pl please review if you have set properly the following settings:
      $Conf{CgiAdminUserGroup} = ‘backuppc’;
      $Conf{CgiAdminUsers} = ‘backuppc’;

      I hope it helps.

  5. Simply desire to say your article is as astounding. The clearness in your post is simply excellent and i could assume you’re an expert on this subject. Well with your permission let me to grab your feed to keep up to date with forthcoming post. Thanks a million and please carry on the gratifying work.

  6. When I initially commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment
    is added I get several emails with the same comment.
    Is there any way you can remove people from that
    service? Appreciate it!

Leave a comment