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
|
||||
@echo "$(BLUE)Validation de la configuration...$(NC)"
|
||||
@validate-borgmatic-config || borgmatic --dry-run -v 0
|
||||
@borgmatic config validate
|
||||
|
||||
test-notifications: ## Teste les notifications ntfy
|
||||
@echo "$(BLUE)Test des notifications ntfy...$(NC)"
|
||||
|
||||
@@ -2,18 +2,28 @@
|
||||
|
||||
Installation et configuration en 5 minutes.
|
||||
|
||||
**Version requise : Borgmatic ≥ 2.0.0**
|
||||
|
||||
## Installation rapide
|
||||
|
||||
```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>
|
||||
cd agence66-borgmatic
|
||||
|
||||
# 2. Configurer les variables d'environnement
|
||||
# 4. Configurer les variables d'environnement
|
||||
cp .env.example .env
|
||||
nano .env # Éditer avec vos valeurs (voir ci-dessous)
|
||||
|
||||
# 3. Installer
|
||||
# 5. Installer
|
||||
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.
|
||||
|
||||
**Version Borgmatic requise : ≥ 2.0.0** (pour l'interpolation des variables d'environnement)
|
||||
|
||||
### Caractéristiques
|
||||
|
||||
- **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)
|
||||
- Accès root
|
||||
- Git installé
|
||||
- **Borgmatic ≥ 2.0.0** (pour l'interpolation des variables d'environnement)
|
||||
|
||||
### Installation rapide
|
||||
|
||||
@@ -64,10 +67,18 @@ sudo ./install.sh
|
||||
Si vous préférez installer manuellement :
|
||||
|
||||
```bash
|
||||
# Installer Borgmatic
|
||||
sudo apt install borgbackup borgmatic # Debian/Ubuntu
|
||||
# Installer Borgmatic ≥ 2.0.0 via pipx (recommandé)
|
||||
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
|
||||
sudo pacman -S borgmatic borg # Arch Linux
|
||||
sudo pacman -S borg # Arch Linux
|
||||
|
||||
# Copier les fichiers
|
||||
sudo mkdir -p /etc/borgmatic/hooks
|
||||
|
||||
84
config.yaml
84
config.yaml
@@ -1,9 +1,15 @@
|
||||
# Configuration Borgmatic pour backup serveur Agence66
|
||||
# Compatible avec Borgmatic 1.7.7
|
||||
# Configuration Borgmatic 2.0 pour backup serveur Agence66
|
||||
# Compatible avec les backups Borg existants
|
||||
#
|
||||
# IMPORTANT: Nécessite Borgmatic ≥ 2.0.0 pour l'interpolation des variables d'environnement
|
||||
|
||||
location:
|
||||
# Chemins sources à sauvegarder
|
||||
source_directories:
|
||||
# Repository Borg - utilise la variable d'environnement
|
||||
repositories:
|
||||
- path: "{BORG_REPO}"
|
||||
label: serveur
|
||||
|
||||
# Chemins sources à sauvegarder
|
||||
source_directories:
|
||||
- /var/www
|
||||
- /srv/minecraftserver
|
||||
- /srv/reddiscordbot
|
||||
@@ -20,65 +26,59 @@ location:
|
||||
- /opt/gitea
|
||||
- /home
|
||||
|
||||
# Repository Borg depuis variable d'environnement
|
||||
repositories:
|
||||
- "{BORG_REPO}"
|
||||
|
||||
# Patterns d'exclusion
|
||||
exclude_patterns:
|
||||
# Patterns d'exclusion
|
||||
exclude_patterns:
|
||||
- "*.log"
|
||||
- "*/cache/*"
|
||||
- "*/tmp/*"
|
||||
- "**/__pycache__"
|
||||
- "*/node_modules/*"
|
||||
|
||||
# Un seul système de fichiers
|
||||
one_file_system: false
|
||||
# Un seul système de fichiers
|
||||
one_file_system: false
|
||||
|
||||
storage:
|
||||
# Format du nom d'archive (compatible avec votre ancien script)
|
||||
archive_name_format: "backup-{now:%Y%m%d-%H%M}"
|
||||
# Format du nom d'archive (compatible avec votre ancien script)
|
||||
archive_name_format: "backup-{now:%Y%m%d-%H%M}"
|
||||
|
||||
# Compression
|
||||
compression: zstd
|
||||
# Compression
|
||||
compression: zstd
|
||||
|
||||
# Options SSH
|
||||
ssh_command: ssh -o StrictHostKeyChecking=accept-new
|
||||
# Options SSH
|
||||
ssh_command: ssh -o StrictHostKeyChecking=accept-new
|
||||
|
||||
retention:
|
||||
# Politique de rétention
|
||||
keep_daily: 7
|
||||
keep_weekly: 4
|
||||
keep_monthly: 6
|
||||
# Politique de rétention
|
||||
keep_daily: 7
|
||||
keep_weekly: 4
|
||||
keep_monthly: 6
|
||||
|
||||
# Préfixe des archives
|
||||
prefix: "backup-"
|
||||
# Préfixe des archives
|
||||
prefix: "backup-"
|
||||
|
||||
consistency:
|
||||
# Vérifications d'intégrité
|
||||
checks:
|
||||
# Vérifications d'intégrité
|
||||
checks:
|
||||
- name: repository
|
||||
frequency: 2 weeks
|
||||
- name: archives
|
||||
frequency: 1 month
|
||||
|
||||
# Fréquence des vérifications
|
||||
check_last: 3
|
||||
# Nombre d'archives à vérifier
|
||||
check_last: 3
|
||||
|
||||
hooks:
|
||||
# Hooks pour notifications ntfy
|
||||
before_backup:
|
||||
# Commandes/hooks pour notifications
|
||||
before_actions:
|
||||
- echo "Backup démarré"
|
||||
|
||||
after_backup:
|
||||
after_backup:
|
||||
- echo "Exécution hook de succès"
|
||||
- /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}"
|
||||
|
||||
# Commandes PostgreSQL/MySQL si nécessaire
|
||||
# postgresql_databases:
|
||||
# - name: all
|
||||
# Commandes PostgreSQL/MySQL si nécessaire
|
||||
# postgresql_databases:
|
||||
# - name: all
|
||||
|
||||
# mysql_databases:
|
||||
# - name: all
|
||||
# mysql_databases:
|
||||
# - name: all
|
||||
|
||||
80
install.sh
80
install.sh
@@ -35,24 +35,82 @@ fi
|
||||
# 1. Installation de Borgmatic et Borg
|
||||
echo -e "${YELLOW}📦 Installation de Borgmatic et Borg...${NC}"
|
||||
|
||||
case $OS in
|
||||
# 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
|
||||
ubuntu|debian)
|
||||
apt-get update
|
||||
apt-get install -y borgbackup borgmatic curl
|
||||
apt-get install -y pipx
|
||||
;;
|
||||
arch|manjaro)
|
||||
pacman -Syu --noconfirm borgmatic borg curl
|
||||
pacman -Syu --noconfirm python-pipx
|
||||
;;
|
||||
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
|
||||
echo -e "${YELLOW}📁 Création des répertoires...${NC}"
|
||||
@@ -114,7 +172,7 @@ else
|
||||
fi
|
||||
|
||||
# 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}"
|
||||
else
|
||||
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
|
||||
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}"
|
||||
else
|
||||
echo -e "${YELLOW}⚠️ Utilisez 'borgmatic --dry-run' pour tester${NC}"
|
||||
|
||||
Reference in New Issue
Block a user