A backup that has never been tested is hope, not strategy. This guide covers automated backup, rotation and restore testing for GLPI.
What to back up
- Database: all GLPI data (tickets, assets, users, settings)
- Files: uploads, documents, plugins, logos and custom settings
- Configuration: GLPI and server configuration files (Apache/Nginx, PHP)
Automated backup script
#!/bin/bash
BACKUP_DIR="/backup/glpi/$(date +%Y-%m-%d)"
mkdir -p "$BACKUP_DIR"
# Database
mysqldump -u glpi -pSENHA --single-transaction glpi | gzip > "$BACKUP_DIR/glpi_db.sql.gz"
# Files
tar -czf "$BACKUP_DIR/glpi_files.tar.gz" /var/lib/glpi /etc/glpi
# Rotation: keep last 30 days
find /backup/glpi -maxdepth 1 -mtime +30 -exec rm -rf {} \;
echo "Backup completed: $BACKUP_DIR"Schedule with cron: 0 2 * * * /opt/scripts/backup-glpi.sh
Backup with Docker
# Database
docker exec glpi-db mysqldump -u glpi -pSENHA glpi | gzip > /backup/glpi_db.sql.gz
# Volumes
tar -czf /backup/glpi_volumes.tar.gz /opt/glpi/data /opt/glpi/configRestore test
- Bring up a test environment (Docker is ideal)
- Restore the database:
gunzip < glpi_db.sql.gz | mysql -u root glpi_test - Restore the files to the corresponding directories
- Access the test GLPI and check: login, tickets, assets, plugins
Disaster Recovery
- RPO (Recovery Point Objective): how much data loss is acceptable? (defines backup frequency)
- RTO (Recovery Time Objective): how long to restore? (defines where and how to store backups)
- Keep an offsite copy (another server, cloud storage)
- Document the restore procedure step by step