Backup & Restore¶
OpsDeck stores data in two places: PostgreSQL (all application data) and the filesystem (attachments and uploaded files). Both must be backed up together to ensure a consistent restore.
What to back up¶
| Component | Location | Method |
|---|---|---|
| Database | PostgreSQL | pg_dump |
| Attachments | /app/data/attachments (container) or ./data/attachments (host) |
File copy / tar |
| Configuration | .env file |
File copy |
Automated backup script¶
#!/bin/bash
# backup-opsdeck.sh
set -euo pipefail
BACKUP_DIR="/backups/opsdeck"
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
RETENTION_DAYS=30
mkdir -p "$BACKUP_DIR"
# Database backup
echo "Backing up database..."
docker-compose exec -T db pg_dump -U opsdeck opsdeck \
| gzip > "$BACKUP_DIR/db_${TIMESTAMP}.sql.gz"
# Attachments backup
echo "Backing up attachments..."
tar -czf "$BACKUP_DIR/attachments_${TIMESTAMP}.tar.gz" ./data/attachments
# Cleanup old backups
find "$BACKUP_DIR" -name "*.gz" -mtime +${RETENTION_DAYS} -delete
echo "Backup complete: $BACKUP_DIR/*_${TIMESTAMP}.*"
Schedule via cron:
Restore procedure¶
1. Stop the application¶
2. Restore the database¶
# Drop and recreate the database
docker-compose exec db psql -U opsdeck -c "DROP DATABASE opsdeck;"
docker-compose exec db psql -U opsdeck -c "CREATE DATABASE opsdeck;"
# Restore from backup
gunzip -c /backups/opsdeck/db_20260324_020000.sql.gz \
| docker-compose exec -T db psql -U opsdeck opsdeck
3. Restore attachments¶
4. Restart¶
Kubernetes backup¶
For Helm deployments, adapt the strategy:
- Use
kubectl execinstead ofdocker-compose execto runpg_dump. - For external PostgreSQL (RDS/Aurora), use the provider's native backup (automated snapshots, point-in-time recovery).
- For attachment PVCs, use your storage provider's snapshot mechanism or Velero for volume-level backups.
Verification¶
After any restore, verify:
- Application starts without migration errors.
- Dashboard loads with correct data.
- Attachments are accessible (open any asset or policy with uploaded files).
- Audit log contains expected history.