132 lines
4.9 KiB
Makefile
132 lines
4.9 KiB
Makefile
# Makefile pour Borgmatic - Agence66
|
|
# Usage: make [commande]
|
|
|
|
.PHONY: help install test backup list restore healthcheck logs status clean
|
|
|
|
# Couleurs pour l'affichage
|
|
BLUE := \033[0;34m
|
|
GREEN := \033[0;32m
|
|
YELLOW := \033[1;33m
|
|
NC := \033[0m
|
|
|
|
help: ## Affiche cette aide
|
|
@echo "$(BLUE)Borgmatic - Agence66$(NC)"
|
|
@echo ""
|
|
@echo "$(YELLOW)Commandes disponibles:$(NC)"
|
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " $(GREEN)%-20s$(NC) %s\n", $$1, $$2}'
|
|
|
|
install: ## Installe Borgmatic et configure le système
|
|
@echo "$(BLUE)Installation de Borgmatic...$(NC)"
|
|
sudo ./install.sh
|
|
|
|
test-config: ## Valide la configuration Borgmatic
|
|
@echo "$(BLUE)Validation de la configuration...$(NC)"
|
|
@sudo bash -c 'set -a && source /etc/borgmatic/.env && set +a && borgmatic config validate'
|
|
|
|
test-notifications: ## Teste les notifications ntfy
|
|
@echo "$(BLUE)Test des notifications ntfy...$(NC)"
|
|
./scripts/test-notifications.sh
|
|
|
|
healthcheck: ## Vérifie la santé du système de backup
|
|
@echo "$(BLUE)Vérification de la santé du système...$(NC)"
|
|
sudo ./scripts/healthcheck.sh
|
|
|
|
dry-run: ## Simule un backup sans l'exécuter
|
|
@echo "$(BLUE)Simulation du backup (dry-run)...$(NC)"
|
|
@sudo bash -c 'set -a && source /etc/borgmatic/.env && set +a && borgmatic --dry-run --verbosity 2'
|
|
|
|
backup: ## Exécute un backup manuel
|
|
@echo "$(BLUE)Exécution du backup...$(NC)"
|
|
@sudo bash -c 'set -a && source /etc/borgmatic/.env && set +a && borgmatic --verbosity 1 --stats'
|
|
|
|
backup-verbose: ## Exécute un backup manuel avec détails
|
|
@echo "$(BLUE)Exécution du backup (mode verbeux)...$(NC)"
|
|
@sudo bash -c 'set -a && source /etc/borgmatic/.env && set +a && borgmatic --verbosity 2 --stats --list'
|
|
|
|
list: ## Liste toutes les archives de backup
|
|
@echo "$(BLUE)Archives disponibles:$(NC)"
|
|
@sudo bash -c 'set -a && source /etc/borgmatic/.env && set +a && borgmatic list'
|
|
|
|
list-files: ## Liste les fichiers de la dernière archive
|
|
@echo "$(BLUE)Fichiers de la dernière archive:$(NC)"
|
|
@sudo bash -c 'set -a && source /etc/borgmatic/.env && set +a && borgmatic list --archive latest'
|
|
|
|
info: ## Affiche les informations sur le repository
|
|
@echo "$(BLUE)Informations sur le repository:$(NC)"
|
|
@sudo bash -c 'set -a && source /etc/borgmatic/.env && set +a && borgmatic info'
|
|
|
|
restore: ## Lance le script de restauration interactive
|
|
@echo "$(BLUE)Restauration interactive...$(NC)"
|
|
sudo ./scripts/restore.sh
|
|
|
|
check: ## Vérifie l'intégrité du repository et des archives
|
|
@echo "$(BLUE)Vérification de l'intégrité...$(NC)"
|
|
@sudo bash -c 'set -a && source /etc/borgmatic/.env && set +a && borgmatic check --verbosity 1'
|
|
|
|
prune: ## Nettoie les anciennes archives selon la politique de rétention
|
|
@echo "$(YELLOW)Nettoyage des anciennes archives...$(NC)"
|
|
@sudo bash -c 'set -a && source /etc/borgmatic/.env && set +a && borgmatic prune --verbosity 1'
|
|
|
|
compact: ## Compacte le repository pour libérer de l'espace
|
|
@echo "$(YELLOW)Compactage du repository...$(NC)"
|
|
@sudo bash -c 'set -a && source /etc/borgmatic/.env && set +a && borg compact $${BORG_REPO}'
|
|
|
|
status: ## Affiche le statut du timer systemd
|
|
@echo "$(BLUE)Statut du timer Borgmatic:$(NC)"
|
|
@systemctl status borgmatic.timer --no-pager
|
|
@echo ""
|
|
@echo "$(BLUE)Prochaines exécutions:$(NC)"
|
|
@systemctl list-timers | grep borgmatic
|
|
|
|
logs: ## Affiche les logs du service
|
|
@echo "$(BLUE)Logs du service Borgmatic:$(NC)"
|
|
journalctl -u borgmatic.service -n 50 --no-pager
|
|
|
|
logs-follow: ## Suit les logs en temps réel
|
|
@echo "$(BLUE)Logs en temps réel (Ctrl+C pour arrêter):$(NC)"
|
|
journalctl -u borgmatic.service -f
|
|
|
|
enable: ## Active et démarre le timer systemd
|
|
@echo "$(GREEN)Activation du timer...$(NC)"
|
|
sudo systemctl enable borgmatic.timer
|
|
sudo systemctl start borgmatic.timer
|
|
@echo "$(GREEN)Timer activé !$(NC)"
|
|
|
|
disable: ## Désactive le timer systemd
|
|
@echo "$(YELLOW)Désactivation du timer...$(NC)"
|
|
sudo systemctl disable borgmatic.timer
|
|
sudo systemctl stop borgmatic.timer
|
|
@echo "$(YELLOW)Timer désactivé$(NC)"
|
|
|
|
restart-timer: ## Redémarre le timer systemd
|
|
@echo "$(BLUE)Redémarrage du timer...$(NC)"
|
|
sudo systemctl restart borgmatic.timer
|
|
@systemctl status borgmatic.timer --no-pager
|
|
|
|
env-example: ## Affiche un exemple de fichier .env
|
|
@cat .env.example
|
|
|
|
edit-config: ## Édite la configuration Borgmatic
|
|
@sudo nano /etc/borgmatic/config.yaml
|
|
|
|
edit-env: ## Édite les variables d'environnement
|
|
@sudo nano /etc/borgmatic/.env
|
|
|
|
clean: ## Nettoie les fichiers temporaires
|
|
@echo "$(YELLOW)Nettoyage...$(NC)"
|
|
@rm -f *.log
|
|
@rm -rf restore/ restore-*/
|
|
@echo "$(GREEN)Nettoyage terminé$(NC)"
|
|
|
|
quick-setup: ## Configuration rapide (copie .env.example vers .env)
|
|
@if [ ! -f .env ]; then \
|
|
echo "$(BLUE)Création du fichier .env...$(NC)"; \
|
|
cp .env.example .env; \
|
|
echo "$(GREEN)Fichier .env créé !$(NC)"; \
|
|
echo "$(YELLOW)Éditez maintenant .env avec vos vraies valeurs:$(NC)"; \
|
|
echo " nano .env"; \
|
|
else \
|
|
echo "$(YELLOW)Le fichier .env existe déjà$(NC)"; \
|
|
fi
|
|
|