Backup Restore
Backup & Restore Guide#
Backup strategies and recovery procedures.
Database Backups#
SQLite#
Backup:
# Stop ncps (recommended)
systemctl stop ncps
# Copy database
cp /var/lib/ncps/db/db.sqlite /backup/db.sqlite.$(date +%Y%m%d)
# Restart ncps
systemctl start ncpsRestore:
systemctl stop ncps
cp /backup/db.sqlite.20240101 /var/lib/ncps/db/db.sqlite
systemctl start ncpsPostgreSQL#
Backup:
pg_dump -h localhost -U ncps ncps > /backup/ncps.sqlRestore:
psql -h localhost -U ncps ncps < /backup/ncps.sqlMySQL#
Backup:
mysqldump -u ncps -p ncps > /backup/ncps.sqlRestore:
mysql -u ncps -p ncps < /backup/ncps.sqlStorage Backups#
Local Storage#
Backup:
tar -czf /backup/ncps-storage.tar.gz /var/lib/ncps/Restore:
tar -xzf /backup/ncps-storage.tar.gz -C /S3 Storage#
S3 has built-in durability. Enable versioning for protection:
aws s3api put-bucket-versioning \
--bucket ncps-cache \
--versioning-configuration Status=EnabledBackup Strategies#
Development#
- Database: Daily backups
- Storage: Optional (can rebuild)
Production Single-Instance#
- Database: Daily automated backups
- Storage: Weekly backups or S3 with versioning
Production HA#
- Database: Automated backups with replication
- Storage: S3 with versioning (built-in)
- Redis: Optional (ephemeral locks)
Disaster Recovery#
- Stop ncps instances
- Restore database from backup
- Restore storage from backup (if local)
- Start ncps instances
- Verify functionality