Aller au contenu principal

Lab 12.1 - Administration Production

Objectifs​

  • Appliquer les best practices
  • Configurer la maintenance
  • Implémenter des backups
  • Monitorer la santé système

Exercice 1: Script de Backup​

# Backup automatique
cat > backup.sh << 'EOF'
#!/bin/bash
BACKUP_DIR="/backup"
SOURCE="/data"
DATE=$(date +%Y%m%d_%H%M%S)
tar -czf "$BACKUP_DIR/backup-$DATE.tar.gz" "$SOURCE"
find "$BACKUP_DIR" -name "*.tar.gz" -mtime +7 -delete
EOF

chmod +x backup.sh

Exercice 2: Health Checks​

# Script de vérification
cat > health-check.sh << 'EOF'
#!/bin/bash
# Vérifier services
systemctl is-active nginx || echo "ALERTE: nginx inactif"
# Vérifier espace disque
df -h / | awk 'NR==2 {if ($5+0 > 90) print "ALERTE: Disque > 90%"}'
EOF

chmod +x health-check.sh

Lab créé le: Décembre 2024 - Testé sur Ubuntu 24.04