======Backup avec BackupPC====== ====Installation de BackupPC==== === BackupPC 3.3 :==== BackupPC 3.3 est disponible sur les dépôts officiel de Debian: # apt install backuppc Il faut configurer Apache2, donc commencer par : # rm /etc/apache2/sites-enabled/* Il faut ensuite créer un VirtualHost d'Apache2 dans ///etc/apache2/sites-available// comme ceci : DocumentRoot /usr/share/backuppc/cgi-bin Alias /backuppc /usr/share/backuppc/cgi-bin/ AllowOverride None Allow from all Options ExecCGI FollowSymlinks AddHandler cgi-script .cgi DirectoryIndex index.cgi AuthUserFile /etc/backuppc/htpasswd AuthType basic AuthName "BackupPC admin" require valid-user Puis de l'activer : # a2ensite backuppc.conf # systemctl reload apache2 On va aussi définir un mot de passe a l'utilisateur backuppc en rentrant la commande : # htpasswd /etc/backuppc/htpasswd backuppc Il faut ensuite créer la clés SSH de l'utilisateur backuppc en lançant les commandes : # sudo -i -u backuppc # ssh-keygen -t rsa -b 4096 # exit Attention à ne pas mettre de Passphrase a la clé. ===Facultatif=== Pour changer l'emplacement de travail de BackupPC (en l’occurrence des backups), il faut d'abord copier le dossier de travail dans la nouvelle destination : # rsync -aAXv /var/lib/backuppc /path/to/dest/ puis de modifier les champs suivants dans la fichier ///etc/backuppc/config.pl// : $Conf{TopDir} = '/path/to/dest/'; $Conf{LogDir} = '/path/to/dest/log'; Puis relancer le service # systemctl restart backuppc ==== BackupPC 4 :==== Attention, cela nécessite de compiler le packet. J'ai donc réalisé ce script pour le faire a votre place :) #!/bin/bash if [[ $EUID -ne 0 ]]; then echo "This script must be run as root" exit 1 fi echo -e "CAREFUL !\nIf you're installing from backuppc 3, backups and hosts will (normally) be conserved, \nBUT some configuration need to be changed manually by you (Apache2, backup settings,...).\nBackup your /etc/backuppc directory, and Good luck !" read -n 1 -s -r -p "Press any key to continue" echo "PURGE DE BACKUPPC ET AJOUT DES DÉPENDENCES" apt remove backuppc apt-get install -y par acl libacl1-dev apache2 apache2-utils libapache2-mod-perl2 glusterfs-client par2 perl smbclient rsync tar gcc zlib1g zlib1g-dev libapache2-mod-scgi rrdtool git make perl-doc libarchive-zip-perl libfile-listing-perl libxml-rss-perl libcgi-session-perl libtime-parsedate-perl if [ ! -d "/var/lib/backuppc" ]; then mkdir /var/lib/backuppc echo "CREATION DE L'UTILISATEUR BACKUPPC" adduser --system --home /var/lib/backuppc --group --disabled-password --shell /bin/bash backuppc mkdir -p /var/lib/backuppc/.ssh ssh-keygen -q -t rsa -b 4096 -N '' -C "BackupPC key" -f /var/lib/backuppc/.ssh/id_rsa echo -e "BatchMode yes\nStrictHostKeyChecking accept-new" > /var/lib/backuppc/.ssh/config chmod 700 /var/lib/backuppc/.ssh && chmod 600 /var/lib/backuppc/.ssh/id_rsa && chmod 644 /var/lib/backuppc/.ssh/id_rsa.pub && chmod 644 /var/lib/backuppc/.ssh/config && chown -R backuppc:backuppc /var/lib/backuppc/.ssh fi pushd `mktemp -d` mkdir backuppc rsync-bpc backuppc-xs echo "RECUPERATION DES DÉPOTS BACKUPPC" curl -s https://api.github.com/repos/backuppc/backuppc/releases/latest | grep "browser_download_url.*.tar.gz" | cut -d : -f 2,3 | tr -d \" | wget -qi - -O backuppc.tar.gz curl -s https://api.github.com/repos/backuppc/rsync-bpc/releases/latest | grep "browser_download_url.*.tar.gz" | cut -d : -f 2,3 | tr -d \" | wget -qi - -O rsync-bpc.tar.gz curl -s https://api.github.com/repos/backuppc/backuppc-xs/releases/latest | grep "browser_download_url.*.tar.gz" | cut -d : -f 2,3 | tr -d \" | wget -qi - -O backuppc-xs.tar.gz echo "COMPILATION DE BACKUPPC-XS" tar -xzf backuppc-xs.tar.gz -C backuppc-xs/ cd backuppc-xs/*/ perl Makefile.PL make make test make install cd ../../ echo "COMPILATION DE RSYNC-BPC" tar -xzf rsync-bpc.tar.gz -C rsync-bpc/ cd rsync-bpc/*/ ./configure make make install cd ../../ echo "COMPILATION DE BACKUPPC" tar -xzf backuppc.tar.gz -C backuppc/ cd backuppc/*/ if [ -f "/etc/backuppc/config.pl" ]; then systemctl stop backuppc ./configure.pl --batch --config-path /etc/backuppc/config.pl popd systemctl start backuppc else ./configure.pl --batch --cgi-dir /usr/local/backuppc/cgi-bin --data-dir /var/lib/backuppc --hostname backuppc --html-dir /usr/local/backuppc/cgi-bin --html-dir-url '' --install-dir /usr/local/backuppc --config-dir /etc/backuppc echo "CONFIGURATION DE BACKUPPC" cp systemd/backuppc.service /etc/systemd/system/ && systemctl daemon-reload sed -i "s/{CgiAdminUsers} = '';/{CgiAdminUsers} = 'backuppc';/g" /etc/backuppc/config.pl systemctl enable --now backuppc echo "CONFIGURATION D'APACHE2" cat << EOF > /etc/apache2/sites-available/001-backuppc.conf DocumentRoot /usr/local/backuppc/cgi-bin Alias /hw /var/www/hw/ AllowOverride None Allow from all Options ExecCGI FollowSymlinks DirectoryIndex BackupPC_Admin SetHandler cgi-script AuthUserFile /etc/backuppc/htpasswd AuthType basic AuthName "BackupPC admin" require valid-user EOF sed -i 's/www-data/backuppc/' /etc/apache2/envvars a2dissite 000-default a2enmod cgid && a2ensite 001-backuppc.conf systemctl restart apache2 if [ ! -f "/etc/backuppc/htpasswd" ]; then touch /etc/backuppc/htpasswd htpasswd -b /etc/backuppc/htpasswd 'backuppc' 'password' fi popd fi echo -e "FINI !\nUse the account backuppc with the password 'password'"