Saltar al contenido principal

Lab 12.1 - Administración en producción

Objetivos​

  • Aplicar las mejores prácticas
  • Configurar el mantenimiento
  • Implementar copias de seguridad
  • Monitorizar la salud del sistema

Ejercicio 1: Script de Backup​

# Backup automático
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

Ejercicio 2: Health Checks​

# Script de verificación
cat > health-check.sh << 'EOF'
#!/bin/bash
# Verificar servicios
systemctl is-active nginx || echo "ALERTA: nginx inactivo"
# Verificar espacio en disco
df -h / | awk 'NR==2 {if ($5+0 > 90) print "ALERTA: Disco > 90%"}'
EOF

chmod +x health-check.sh

Lab creado el: Diciembre 2024 - Probado en Ubuntu 24.04