# Backup & Recovery Protecting your Likwid data. ## What to Backup | Component | Location | Priority | |-----------|----------|----------| | PostgreSQL database | Database server | Critical | | Uploaded files | `/uploads` (if configured) | High | | Configuration | `.env` files | High | | SSL certificates | Reverse proxy | Medium | ## Database Backup ### Manual Backup ```bash # Full backup pg_dump -h localhost -U likwid -F c likwid_prod > backup_$(date +%Y%m%d).dump # SQL format (readable) pg_dump -h localhost -U likwid likwid_prod > backup_$(date +%Y%m%d).sql ``` ### Automated Backup Script ```bash #!/bin/bash # /etc/cron.daily/likwid-backup BACKUP_DIR="/var/backups/likwid" DATE=$(date +%Y%m%d_%H%M%S) RETENTION_DAYS=30 # Create backup pg_dump -h localhost -U likwid -F c likwid_prod > "$BACKUP_DIR/likwid_$DATE.dump" # Compress gzip "$BACKUP_DIR/likwid_$DATE.dump" # Remove old backups find "$BACKUP_DIR" -name "*.dump.gz" -mtime +$RETENTION_DAYS -delete # Optional: sync to remote storage # aws s3 cp "$BACKUP_DIR/likwid_$DATE.dump.gz" s3://bucket/backups/ ``` ### Containerized Backup ```bash # If using podman-compose podman exec likwid-prod-db pg_dump -U likwid likwid_prod > backup.sql ``` ## Recovery ### Full Restore ```bash # Drop and recreate database psql -h localhost -U postgres -c "DROP DATABASE IF EXISTS likwid_prod;" psql -h localhost -U postgres -c "CREATE DATABASE likwid_prod OWNER likwid;" # Restore from dump pg_restore -h localhost -U likwid -d likwid_prod backup.dump # Or from SQL psql -h localhost -U likwid likwid_prod < backup.sql ``` ### Point-in-Time Recovery For critical installations, configure PostgreSQL WAL archiving: ```ini # postgresql.conf archive_mode = on archive_command = 'cp %p /var/lib/postgresql/archive/%f' ``` ## Demo Instance Reset The demo instance can be reset to initial state: ```bash # Windows .\scripts\demo-reset.ps1 # Linux ./scripts/demo-reset.sh ``` This removes all data and re-runs migrations with seed data. ## Disaster Recovery Plan ### Preparation 1. Document backup procedures 2. Test restores regularly (monthly) 3. Keep offsite backup copies 4. Document recovery steps ### Recovery Steps 1. Provision new server if needed 2. Install Likwid dependencies 3. Restore database from backup 4. Restore configuration files 5. Start services 6. Verify functionality 7. Update DNS if server changed ### Recovery Time Objective (RTO) Target: 4 hours for full recovery ### Recovery Point Objective (RPO) Target: 24 hours of data loss maximum (with daily backups) ## Testing Backups Monthly backup test procedure: 1. Create test database 2. Restore backup to test database 3. Run verification queries 4. Document results 5. Delete test database