Backup & Restore¶
This guide covers backup and restore procedures for OSGEO-Inject.
Overview¶
The system backs up: - Database: Matomo analytics data - Configuration: Nginx config, Matomo config - Content: Announcements, history, site list
Backup Script¶
Interactive Mode¶
This launches a TUI with options to: - Create full backup - Create partial backup (database/config/content only) - List existing backups - Verify backup integrity - Clean old backups
CLI Mode¶
# Full backup
./scripts/backup.sh -t full
# Database only
./scripts/backup.sh -t database
# List backups
./scripts/backup.sh --list
# Verify checksums
./scripts/backup.sh --verify
Automated Backups¶
NixOS configures daily automated backups:
services.osgeo-inject = {
enableBackups = true;
backupSchedule = "daily"; # or "weekly", or systemd calendar format
backupDir = "/var/backups/osgeo-inject";
};
Check backup status:
Restore Script¶
Interactive Mode¶
This allows you to: - Select a backup to restore - Choose what to restore (full/database/config/content) - Verify backup integrity before restoring
CLI Mode¶
# Restore from specific backup
./scripts/restore.sh -f backups/osgeo-inject_20260302.tar.gz -t full
# Database only
./scripts/restore.sh -f backup.tar.gz -t database
# Skip confirmation (automated restores)
./scripts/restore.sh -f backup.tar.gz --force
Backup Structure¶
osgeo-inject_20260302_120000/
├── manifest.json # Backup metadata
├── database/
│ └── matomo.sql.gz # Database dump
├── config/
│ ├── nginx.conf # Nginx configuration
│ └── matomo/ # Matomo config files
└── content/
├── announcement.json
├── history.json
└── sites.json
Verification¶
Backups include SHA-256 checksums:
# View checksums
cat backups/checksums.txt
# Verify a specific backup
sha256sum -c backups/checksums.txt
Retention Policy¶
By default, backups are retained for 30 days. Configure via:
Recovery Procedures¶
Full System Recovery¶
- Deploy fresh NixOS installation
- Copy latest backup to server
- Run restore script with
--force - Restart services
Database Recovery Only¶
Configuration Recovery¶
Best Practices¶
- Test restores regularly: Don't wait for a disaster
- Off-site backups: Copy backups to remote storage
- Monitor backup jobs: Check systemd timer status
- Encrypt sensitive backups: Use GPG for database dumps