Backup & Recovery
Database backup, recovery key protection, and disaster recovery.
Database Backup
Automated Daily Backup
bash
#!/bin/bash
# /opt/BlueSentinel/backup.sh
BACKUP_DIR="/opt/BlueSentinel/backups"
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
mkdir -p $BACKUP_DIR
pg_dump -U bluesentinel -d bluesentinel -F c -f "$BACKUP_DIR/bluesentinel_$TIMESTAMP.dump"
# Keep only last 30 days
find $BACKUP_DIR -name "*.dump" -mtime +30 -deleteAdd to crontab:
bash
0 2 * * * /opt/BlueSentinel/backup.shRestore from Backup
bash
pg_restore -U bluesentinel -d bluesentinel -c bluesentinel_20260817_020000.dumpRecovery Key Protection
Recovery keys are critical — losing them means you cannot decrypt locked devices:
- Back up the
recovery_keystable separately - Store backups in an encrypted, offsite location
- Test recovery key retrieval regularly
Application Backup
Back up these files:
/opt/BlueSentinel/.env— Environment configuration/etc/systemd/system/bluesentinel.service— Service configuration/etc/nginx/sites-available/bluesentinel— Nginx configuration- TLS certificates
Disaster Recovery
- Provision a new server
- Install PostgreSQL and restore the database backup
- Install BlueSentinel and restore configuration files
- Update DNS to point to the new server
- Agents will automatically reconnect on their next heartbeat cycle (within 60 seconds)
Agents are resilient to server outages. They continue enforcing policies in offline mode and queue alerts until the server is available again.