update for borgmatic 2.0
This commit is contained in:
2
Makefile
2
Makefile
@@ -21,7 +21,7 @@ install: ## Installe Borgmatic et configure le système
|
|||||||
|
|
||||||
test-config: ## Valide la configuration Borgmatic
|
test-config: ## Valide la configuration Borgmatic
|
||||||
@echo "$(BLUE)Validation de la configuration...$(NC)"
|
@echo "$(BLUE)Validation de la configuration...$(NC)"
|
||||||
@validate-borgmatic-config || borgmatic --dry-run -v 0
|
@borgmatic config validate
|
||||||
|
|
||||||
test-notifications: ## Teste les notifications ntfy
|
test-notifications: ## Teste les notifications ntfy
|
||||||
@echo "$(BLUE)Test des notifications ntfy...$(NC)"
|
@echo "$(BLUE)Test des notifications ntfy...$(NC)"
|
||||||
|
|||||||
@@ -2,18 +2,28 @@
|
|||||||
|
|
||||||
Installation et configuration en 5 minutes.
|
Installation et configuration en 5 minutes.
|
||||||
|
|
||||||
|
**Version requise : Borgmatic ≥ 2.0.0**
|
||||||
|
|
||||||
## Installation rapide
|
## Installation rapide
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 1. Cloner le dépôt (si pas déjà fait)
|
# 1. Installer Borgmatic 2.0+ (si pas déjà fait)
|
||||||
|
sudo apt install pipx
|
||||||
|
sudo pipx install borgmatic
|
||||||
|
sudo ln -sf /root/.local/bin/borgmatic /usr/local/bin/borgmatic
|
||||||
|
|
||||||
|
# 2. Vérifier la version
|
||||||
|
borgmatic --version # Doit être ≥ 2.0.0
|
||||||
|
|
||||||
|
# 3. Cloner le dépôt (si pas déjà fait)
|
||||||
git clone <url-du-repo>
|
git clone <url-du-repo>
|
||||||
cd agence66-borgmatic
|
cd agence66-borgmatic
|
||||||
|
|
||||||
# 2. Configurer les variables d'environnement
|
# 4. Configurer les variables d'environnement
|
||||||
cp .env.example .env
|
cp .env.example .env
|
||||||
nano .env # Éditer avec vos valeurs (voir ci-dessous)
|
nano .env # Éditer avec vos valeurs (voir ci-dessous)
|
||||||
|
|
||||||
# 3. Installer
|
# 5. Installer
|
||||||
sudo ./install.sh
|
sudo ./install.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
17
README.md
17
README.md
@@ -6,6 +6,8 @@ Configuration Borgmatic pour le backup automatique du serveur Agence66.
|
|||||||
|
|
||||||
Ce dépôt contient la configuration complète pour effectuer des backups automatiques quotidiens à 3h du matin via Borgmatic et BorgBackup.
|
Ce dépôt contient la configuration complète pour effectuer des backups automatiques quotidiens à 3h du matin via Borgmatic et BorgBackup.
|
||||||
|
|
||||||
|
**Version Borgmatic requise : ≥ 2.0.0** (pour l'interpolation des variables d'environnement)
|
||||||
|
|
||||||
### Caractéristiques
|
### Caractéristiques
|
||||||
|
|
||||||
- **Backup quotidien automatique** à 3h du matin via systemd timer
|
- **Backup quotidien automatique** à 3h du matin via systemd timer
|
||||||
@@ -40,6 +42,7 @@ Ce dépôt contient la configuration complète pour effectuer des backups automa
|
|||||||
- Système Linux (Debian/Ubuntu/Arch/Fedora)
|
- Système Linux (Debian/Ubuntu/Arch/Fedora)
|
||||||
- Accès root
|
- Accès root
|
||||||
- Git installé
|
- Git installé
|
||||||
|
- **Borgmatic ≥ 2.0.0** (pour l'interpolation des variables d'environnement)
|
||||||
|
|
||||||
### Installation rapide
|
### Installation rapide
|
||||||
|
|
||||||
@@ -64,10 +67,18 @@ sudo ./install.sh
|
|||||||
Si vous préférez installer manuellement :
|
Si vous préférez installer manuellement :
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Installer Borgmatic
|
# Installer Borgmatic ≥ 2.0.0 via pipx (recommandé)
|
||||||
sudo apt install borgbackup borgmatic # Debian/Ubuntu
|
sudo apt install pipx
|
||||||
|
sudo pipx install borgmatic
|
||||||
|
|
||||||
|
# Créer les liens symboliques
|
||||||
|
sudo ln -sf /root/.local/bin/borgmatic /usr/local/bin/borgmatic
|
||||||
|
sudo ln -sf /root/.local/bin/generate-borgmatic-config /usr/local/bin/generate-borgmatic-config
|
||||||
|
|
||||||
|
# Installer BorgBackup
|
||||||
|
sudo apt install borgbackup # Debian/Ubuntu
|
||||||
# ou
|
# ou
|
||||||
sudo pacman -S borgmatic borg # Arch Linux
|
sudo pacman -S borg # Arch Linux
|
||||||
|
|
||||||
# Copier les fichiers
|
# Copier les fichiers
|
||||||
sudo mkdir -p /etc/borgmatic/hooks
|
sudo mkdir -p /etc/borgmatic/hooks
|
||||||
|
|||||||
28
config.yaml
28
config.yaml
@@ -1,7 +1,13 @@
|
|||||||
# Configuration Borgmatic pour backup serveur Agence66
|
# Configuration Borgmatic 2.0 pour backup serveur Agence66
|
||||||
# Compatible avec Borgmatic 1.7.7
|
# Compatible avec les backups Borg existants
|
||||||
|
#
|
||||||
|
# IMPORTANT: Nécessite Borgmatic ≥ 2.0.0 pour l'interpolation des variables d'environnement
|
||||||
|
|
||||||
|
# Repository Borg - utilise la variable d'environnement
|
||||||
|
repositories:
|
||||||
|
- path: "{BORG_REPO}"
|
||||||
|
label: serveur
|
||||||
|
|
||||||
location:
|
|
||||||
# Chemins sources à sauvegarder
|
# Chemins sources à sauvegarder
|
||||||
source_directories:
|
source_directories:
|
||||||
- /var/www
|
- /var/www
|
||||||
@@ -20,10 +26,6 @@ location:
|
|||||||
- /opt/gitea
|
- /opt/gitea
|
||||||
- /home
|
- /home
|
||||||
|
|
||||||
# Repository Borg depuis variable d'environnement
|
|
||||||
repositories:
|
|
||||||
- "{BORG_REPO}"
|
|
||||||
|
|
||||||
# Patterns d'exclusion
|
# Patterns d'exclusion
|
||||||
exclude_patterns:
|
exclude_patterns:
|
||||||
- "*.log"
|
- "*.log"
|
||||||
@@ -35,7 +37,6 @@ location:
|
|||||||
# Un seul système de fichiers
|
# Un seul système de fichiers
|
||||||
one_file_system: false
|
one_file_system: false
|
||||||
|
|
||||||
storage:
|
|
||||||
# Format du nom d'archive (compatible avec votre ancien script)
|
# Format du nom d'archive (compatible avec votre ancien script)
|
||||||
archive_name_format: "backup-{now:%Y%m%d-%H%M}"
|
archive_name_format: "backup-{now:%Y%m%d-%H%M}"
|
||||||
|
|
||||||
@@ -45,7 +46,6 @@ storage:
|
|||||||
# Options SSH
|
# Options SSH
|
||||||
ssh_command: ssh -o StrictHostKeyChecking=accept-new
|
ssh_command: ssh -o StrictHostKeyChecking=accept-new
|
||||||
|
|
||||||
retention:
|
|
||||||
# Politique de rétention
|
# Politique de rétention
|
||||||
keep_daily: 7
|
keep_daily: 7
|
||||||
keep_weekly: 4
|
keep_weekly: 4
|
||||||
@@ -54,7 +54,6 @@ retention:
|
|||||||
# Préfixe des archives
|
# Préfixe des archives
|
||||||
prefix: "backup-"
|
prefix: "backup-"
|
||||||
|
|
||||||
consistency:
|
|
||||||
# Vérifications d'intégrité
|
# Vérifications d'intégrité
|
||||||
checks:
|
checks:
|
||||||
- name: repository
|
- name: repository
|
||||||
@@ -62,18 +61,19 @@ consistency:
|
|||||||
- name: archives
|
- name: archives
|
||||||
frequency: 1 month
|
frequency: 1 month
|
||||||
|
|
||||||
# Fréquence des vérifications
|
# Nombre d'archives à vérifier
|
||||||
check_last: 3
|
check_last: 3
|
||||||
|
|
||||||
hooks:
|
# Commandes/hooks pour notifications
|
||||||
# Hooks pour notifications ntfy
|
before_actions:
|
||||||
before_backup:
|
|
||||||
- echo "Backup démarré"
|
- echo "Backup démarré"
|
||||||
|
|
||||||
after_backup:
|
after_backup:
|
||||||
|
- echo "Exécution hook de succès"
|
||||||
- /etc/borgmatic/hooks/ntfy-success.sh "{archive_name}" "{stats}"
|
- /etc/borgmatic/hooks/ntfy-success.sh "{archive_name}" "{stats}"
|
||||||
|
|
||||||
on_error:
|
on_error:
|
||||||
|
- echo "Exécution hook d'erreur"
|
||||||
- /etc/borgmatic/hooks/ntfy-error.sh "{error}"
|
- /etc/borgmatic/hooks/ntfy-error.sh "{error}"
|
||||||
|
|
||||||
# Commandes PostgreSQL/MySQL si nécessaire
|
# Commandes PostgreSQL/MySQL si nécessaire
|
||||||
|
|||||||
76
install.sh
76
install.sh
@@ -35,24 +35,82 @@ fi
|
|||||||
# 1. Installation de Borgmatic et Borg
|
# 1. Installation de Borgmatic et Borg
|
||||||
echo -e "${YELLOW}📦 Installation de Borgmatic et Borg...${NC}"
|
echo -e "${YELLOW}📦 Installation de Borgmatic et Borg...${NC}"
|
||||||
|
|
||||||
|
# Vérifier si Borgmatic est déjà installé
|
||||||
|
if command -v borgmatic &> /dev/null; then
|
||||||
|
BORGMATIC_VERSION=$(borgmatic --version 2>&1 | grep -oP '\d+\.\d+\.\d+' | head -1)
|
||||||
|
MAJOR_VERSION=$(echo $BORGMATIC_VERSION | cut -d. -f1)
|
||||||
|
|
||||||
|
if [ "$MAJOR_VERSION" -lt 2 ]; then
|
||||||
|
echo -e "${YELLOW}⚠️ Borgmatic $BORGMATIC_VERSION détecté (version < 2.0)${NC}"
|
||||||
|
echo -e "${YELLOW} Cette configuration nécessite Borgmatic ≥ 2.0.0${NC}"
|
||||||
|
echo -e "${YELLOW} Installation via pipx recommandée...${NC}"
|
||||||
|
|
||||||
|
# Installer pipx si pas déjà fait
|
||||||
case $OS in
|
case $OS in
|
||||||
ubuntu|debian)
|
ubuntu|debian)
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get install -y borgbackup borgmatic curl
|
apt-get install -y pipx
|
||||||
;;
|
;;
|
||||||
arch|manjaro)
|
arch|manjaro)
|
||||||
pacman -Syu --noconfirm borgmatic borg curl
|
pacman -Syu --noconfirm python-pipx
|
||||||
;;
|
;;
|
||||||
fedora|rhel|centos)
|
fedora|rhel|centos)
|
||||||
dnf install -y borgbackup borgmatic curl
|
dnf install -y pipx
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo -e "${RED}❌ Distribution non supportée: $OS${NC}"
|
|
||||||
exit 1
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
echo -e "${GREEN}✅ Borgmatic et Borg installés${NC}"
|
# Installer Borgmatic via pipx
|
||||||
|
pipx install borgmatic --force
|
||||||
|
|
||||||
|
# Créer les liens symboliques
|
||||||
|
ln -sf /root/.local/bin/borgmatic /usr/local/bin/borgmatic
|
||||||
|
ln -sf /root/.local/bin/generate-borgmatic-config /usr/local/bin/generate-borgmatic-config
|
||||||
|
|
||||||
|
echo -e "${GREEN}✅ Borgmatic 2.0+ installé via pipx${NC}"
|
||||||
|
else
|
||||||
|
echo -e "${GREEN}✅ Borgmatic $BORGMATIC_VERSION déjà installé${NC}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo -e "${YELLOW}Installation de Borgmatic via pipx...${NC}"
|
||||||
|
|
||||||
|
# Installer pipx
|
||||||
|
case $OS in
|
||||||
|
ubuntu|debian)
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y pipx
|
||||||
|
;;
|
||||||
|
arch|manjaro)
|
||||||
|
pacman -Syu --noconfirm python-pipx
|
||||||
|
;;
|
||||||
|
fedora|rhel|centos)
|
||||||
|
dnf install -y pipx
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Installer Borgmatic
|
||||||
|
pipx install borgmatic
|
||||||
|
|
||||||
|
# Créer les liens symboliques
|
||||||
|
ln -sf /root/.local/bin/borgmatic /usr/local/bin/borgmatic
|
||||||
|
ln -sf /root/.local/bin/generate-borgmatic-config /usr/local/bin/generate-borgmatic-config
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Installer Borg si pas déjà fait
|
||||||
|
if ! command -v borg &> /dev/null; then
|
||||||
|
case $OS in
|
||||||
|
ubuntu|debian)
|
||||||
|
apt-get install -y borgbackup curl
|
||||||
|
;;
|
||||||
|
arch|manjaro)
|
||||||
|
pacman -Syu --noconfirm borg curl
|
||||||
|
;;
|
||||||
|
fedora|rhel|centos)
|
||||||
|
dnf install -y borgbackup curl
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${GREEN}✅ Installation terminée${NC}"
|
||||||
|
|
||||||
# 2. Créer les répertoires nécessaires
|
# 2. Créer les répertoires nécessaires
|
||||||
echo -e "${YELLOW}📁 Création des répertoires...${NC}"
|
echo -e "${YELLOW}📁 Création des répertoires...${NC}"
|
||||||
@@ -114,7 +172,7 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Test de la configuration (sans exécuter de backup)
|
# Test de la configuration (sans exécuter de backup)
|
||||||
if validate-borgmatic-config > /dev/null 2>&1; then
|
if borgmatic config validate > /dev/null 2>&1; then
|
||||||
echo -e "${GREEN}✅ Configuration valide${NC}"
|
echo -e "${GREEN}✅ Configuration valide${NC}"
|
||||||
else
|
else
|
||||||
echo -e "${YELLOW}⚠️ Validation de la configuration...${NC}"
|
echo -e "${YELLOW}⚠️ Validation de la configuration...${NC}"
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ echo -e "${YELLOW}🔍 Vérification de la configuration...${NC}"
|
|||||||
if [ -f /etc/borgmatic/config.yaml ]; then
|
if [ -f /etc/borgmatic/config.yaml ]; then
|
||||||
echo -e "${GREEN}✅ Fichier de configuration trouvé${NC}"
|
echo -e "${GREEN}✅ Fichier de configuration trouvé${NC}"
|
||||||
|
|
||||||
if validate-borgmatic-config > /dev/null 2>&1; then
|
if borgmatic config validate > /dev/null 2>&1; then
|
||||||
echo -e "${GREEN}✅ Configuration valide${NC}"
|
echo -e "${GREEN}✅ Configuration valide${NC}"
|
||||||
else
|
else
|
||||||
echo -e "${YELLOW}⚠️ Utilisez 'borgmatic --dry-run' pour tester${NC}"
|
echo -e "${YELLOW}⚠️ Utilisez 'borgmatic --dry-run' pour tester${NC}"
|
||||||
|
|||||||
Reference in New Issue
Block a user