Mac OS X : installation de BackupPC

BackupPC est un logiciel de sauvegarde de serveurs distants avec prise en charge des protocoles SSH, rsync et SMB. Cet article présente son installation sur un poste Mac OS X.
Installation du serveur web
BackupPC requiert l’installation d’un serveur web avec prise en charge des scripts Perl. Ces sujets étant déjà traités dans de précédents articles, je vous y renvoie :
Installation de BackupPC
Les dépendances suivantes à installer :
$ sudo port install p5-compress-zlib p5-file-rsyncp proctools
L’installation de BackupPC est effectuée dans le répertoire /opt/local pour rester dans l’esprit MacPorts :
$ cd /opt/local/src
$ tar xzf BackupPC.tar.gz
$ sudo perl configure.pl
--> Full path to existing main config.pl []?
--> Are these paths correct? [y]?
--> BackupPC will run on host [bhuisgen.local]?
--> Install directory (full path) [/usr/local/BackupPC]? /opt/local/share/backuppc
--> Data directory (full path) [/data/BackupPC]? /Volumes/WORK/backup/backuppc
--> Compression level [3]?
--> Apache image directory (full path) []? /opt/local/www/backuppc/images
--> URL for image directory (omit http://host; starts with '/') []? /backuppc/images
--> CGI bin directory (full path) []? /opt/local/www/backuppc
L’installation effectue la copie des fichiers de configuration dans /etc. Les modifications suivantes sont nécessaires pour corriger l’installation dans le répertoire /opt/local/etc :
$ sudo mv BackupPC/ /opt/local/etc/backuppc
$ sudo mv /var/log/BackupPC/ /opt/local/var/log/backuppc
$ sudo chown root:admin /opt/local/etc/backuppc
$ sudo chown root:admin /opt/local/var/log/backuppc/
Le fichier /opt/local/share/backuppc/lib/BackupPC/Lib.pm est à modifier pour lui préciser les répertoires /opt/local/etc/backuppc et /opt/local/var/log/backuppc :
1--- Lib.pm.old 2009-04-10 00:56:46.000000000 +0200
2+++ Lib.pm 2009-04-10 00:57:33.000000000 +0200
3@@ -128,8 +128,8 @@
4 useFHS => $useFHS,
5 TopDir => $topDir,
6 InstallDir => $installDir,
7- ConfDir => $confDir eq "" ? '/etc/BackupPC' : $confDir,
8- LogDir => '/var/log/BackupPC',
9+ ConfDir => $confDir eq "" ? '/opt/local/etc/backuppc' : $confDir,
10+ LogDir => '/opt/local/var/log/backuppc',
Les répertoires sont également à modifier dans le fichier principal de configuration /opt/local/etc/backuppc/config.pl :
$Conf{TopDir} = '/Volumes/WORK/backup/backuppc';
$Conf{ConfDir} = '/opt/local/etc/backuppc';
$Conf{LogDir} = '/opt/local/var/log/backuppc';
$Conf{InstallDir} = '/opt/local/share/backuppc';
$Conf{CgiDir} = '/opt/local/www/backuppc';
Vérifiez dans la configuration que root est bien l’utilisateur exécutant le démon BackupPC :
$Conf{BackupPCUser} = 'root';
{{< notification is-info >}}
L’utilisateur backuppc pourrait être utilisé mais la configuration CGI est à adapter en conséquence.
{{</ notification >}}
Par défaut, tous les droits d’administration de BackupPC sont autorisés :
$Conf{CgiAdminUserGroup} = '';
$Conf{CgiAdminUsers} = '*';
Un lien symbolique est nécessaire pour le fonctionnement de l’interface web :
$ cd /opt/local/www/backuppc
$ sudo ln -s ./BackupPC_Admin index.cgi
Le script de démarrage de BackupPC est à créer :
$ cd /opt/local/etc/LaunchDaemons/fr.hbis.backuppc
$ vim backuppc.wrapper
1#!/bin/bash
2#
3# daemondo support script for BackupPC
4#
5# Boris HUISGEN <bhuisgen@hbis.fr>
6#
7
8# backuppc directory, needed to pkill
9BACKUPPC_DIR="/opt/local/share/backuppc/"
10# command to start daemon
11CMD="/opt/local/bin/perl /opt/local/share/backuppc/bin/BackupPC"
12
13#
14# Init
15#
16prefix=/opt/local
17
18#
19# Start
20#
21
22Start() {
23 $CMD
24}
25
26#
27# Stop
28#
29
30Stop() {
31 pkill -f $BACKUPPC_DIR
32}
33
34#
35# Restart
36#
37
38Restart() {
39 Stop
40 Start
41}
42
43#
44# Run
45#
46
47Run() {
48 case $1 in
49 start) Start ;;
50 stop) Stop ;;
51 restart) Restart ;;
52 *) echo "$0: unknown argument: $1" ;;
53 esac
54}
55
56#
57# Run a phase based on the selector
58#
59Run $1
Le script de launchd également, ce dernier utilisant daemondo fourni par MacPorts :
$ vim fr.hbis.backuppc.plist
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>Debug</key>
6 <false/>
7 <key>Label</key>
8 <string>fr.hbis.backuppc</string>
9 <key>OnDemand</key>
10 <false/>
11 <key>ProgramArguments</key>
12 <array>
13 <string>/opt/local/bin/daemondo</string>
14 <string>--label=backuppc</string>
15 <string>--start-cmd</string>
16 <string>/opt/local/etc/LaunchDaemons/org.macports.backuppc/backuppc.wrapper</string>
17 <string>start</string>
18 <string>;</string>
19 <string>--stop-cmd</string>
20 <string>/opt/local/etc/LaunchDaemons/org.macports.backuppc/backuppc.wrapper</string>
21 <string>stop</string>
22 <string>;</string>
23 <string>--restart-cmd</string>
24 <string>/opt/local/etc/LaunchDaemons/orgs.macports.backuppc/backuppc.wrapper</string>
25 <string>restart</string>
26 <string>;</string>
27 <string>--pid=none</string>
28 </array>
29 <key>RunAtLoad</key>
30 <false/>
31</dict>
32</plist>
On référence le script pour démarrer BackupPC :
$ sudo launchctl load -w fr.hbis.backuppc.plist
Si tout est OK, BackupPC doit être en exécution.
Son interface de gestion est accessible à cette adresse : http://localhost/backuppc/.