Quick fix to BackupPC start on CentOS 7

A 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:

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

First of all is needed 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 service starts correctly but, in my case, when server is restarted the service is not automatically up, let’s dig deeper to find what’s going on. If we check if the service is enabled we get this:

# systemctl is-enabled backuppc
 static

But what “static” exactly means? From this page (netsuso comment) we could read the following explanation:

Static units are those which cannot be enabled/disabled, but it doesn’t mean they are always executed. They will only if another unit depends on them, or if they are manually started.
Actually, static units are simply those without an [Install] section. As enabling units means just creating a symlink to wherever [Install] mandates, those units without [Install] section cannot be enabled, as systemctl doesn’t know where to place the symlink.
Of course, you can still manually create a symlink from a static unit to (for instance) /etc/systemd/system/multi-user.target.wants/, and it will be executed as any other enabled unit. But I suppose static units are not intended to be enabled in that way, and most probably you shouldn’t need to do it wink

So, what happens if we change service descriptor and we 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.

It’s time to reboot our server and check if unit is automatically started. Now the service should start without any problems.

That’s all folks!

“Simplicity is the ultimate sophistication”
— Leonardo da Vinci

One thought on “Quick fix to BackupPC start on CentOS 7

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s