2023-03-16 10:25:07 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Ajouter les backports bullseye.
|
2023-03-16 10:33:01 +01:00
|
|
|
if [ $(grep -Rih backport /etc/apt/sources.list* |grep -v "^#" | wc -l) -ne 0 ]; then
|
2023-03-16 10:25:07 +01:00
|
|
|
echo "Backports apt configuration: PASSED"
|
|
|
|
else
|
|
|
|
echo "deb http://ftp.fr.debian.org/debian/ bullseye-backports main" > /etc/apt/sources.list.d/backports.list
|
|
|
|
echo "Backports apt configuration: DONE"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Installer les paquets nécessaires.
|
|
|
|
borgmatic --version > /dev/null
|
|
|
|
STATE1=$?
|
|
|
|
borgbackup --version > /dev/null
|
|
|
|
STATE2=$?
|
|
|
|
if [ $STATE1 -eq 0 ] && [ $STATE2 -eq 0 ]; then
|
|
|
|
echo "Borgmatic package install: PASSED"
|
|
|
|
else
|
|
|
|
apt update && apt install -t bullseye-backports borgmatic borgbackup
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "Borgmatic package install: DONE"
|
|
|
|
else
|
|
|
|
echo "Borgmatic package install: FAILED"
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Forcer l'action create dans le service Systemd de Borgmatic.
|
|
|
|
if [ $(grep "/usr/bin/borgmatic create" /lib/systemd/system/borgmatic.service | wc -l) -eq 1 ]; then
|
|
|
|
echo "Borgmatic service patch: PASSED"
|
|
|
|
else
|
|
|
|
sed -i s#/usr/bin/borgmatic#/usr/bin/borgmatic\ create# /lib/systemd/system/borgmatic.service && systemctl daemon-reload
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "Borgmatic service path: DONE"
|
|
|
|
else
|
|
|
|
echo "Borgmatic service path: FAILED"
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Créer des clés ssh pour l'utilisateur root (si besoin).
|
|
|
|
# Créer des clés ssh pour l'utilisateur root (si besoin).
|
|
|
|
if [ $(ls /root/.ssh/*pub 2> /dev/null | wc -l) -ne 0 ]; then
|
|
|
|
echo "SSH root key creation: PASSED"
|
|
|
|
else
|
|
|
|
sudo ssh-keygen -t ed25519
|
|
|
|
echo "SSH root key creation: DONE"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Peupler le dossier de configruation de Borgmatic.
|
2023-03-16 10:40:05 +01:00
|
|
|
if [ -d /etc/borgmatic ]; then
|
|
|
|
echo "Borgmatic configuration files: PASSED"
|
|
|
|
else
|
|
|
|
mkdir -p /etc/borgmatic
|
|
|
|
cd /etc/borgmatic
|
|
|
|
URL=https://git.a-lec.org/a-lec/commissions/infrastructure/sauvegardes/-/raw/main/Plan%20Borg/
|
|
|
|
wget -nv $URL/models/excludes
|
|
|
|
wget -nv $URL/models/model-conf-remote-client.yaml -O /etc/borgmatic/config.yaml
|
|
|
|
echo "Borgmatic configuration files: DONE"
|
|
|
|
fi
|
2023-03-16 10:25:07 +01:00
|
|
|
|
|
|
|
# Vérifier que la configuration Borgmatic.
|
|
|
|
validate-borgmatic-config
|
2023-03-16 10:40:05 +01:00
|
|
|
echo "Borgmatic configuration check: DONE."
|
|
|
|
|
|
|
|
echo "ALL OK."
|
|
|
|
|