Overview
Millennium Potters uses a multi-layered backup strategy combining CockroachDB’s native backups with application-level exports to Cloudinary.Backup Types
1. CockroachDB Automatic Backups
Production database backups (managed by CockroachDB Serverless):- Frequency: Hourly
- Retention: 30 days
- Type: Full database snapshots
- Location: CockroachDB managed storage
- Recovery: Point-in-Time Recovery (PITR)
These backups are automatic and require no manual intervention. They protect against database-level failures.
2. Application-Level Backups
The backend API provides manual backup creation with flexible options:includeAuditLogs: Include audit log entries (default:false)includeSessions: Include active user sessions (default:false)location:"local","cloud", or"both"(default:"local")
Backup Operations
List All Backups
Download a Backup
- If stored in Cloudinary: Redirects to the cloud URL
- If stored locally: Streams the file directly
backend/src/controllers/backup.controller.ts:53-78
Delete a Backup
Restore Operations
Restore from Backup File
- System must be in maintenance mode during restore
- All users will be logged out after restore
- The restore process validates backup format before proceeding
backend/src/controllers/backup.controller.ts:108-132
System Reset (Emergency)
Point-in-Time Recovery (PITR)
CockroachDB PITR
Restore to any point within the last 30 days:- Accidental data deletion
- Incorrect bulk updates
- Rollback after failed migration
- Recovery from data corruption
pg_dump Method (Manual Backups)
Following the documented deployment procedures:No format conversion needed -
pg_dump produces PostgreSQL-compatible SQL that works directly with CockroachDB.Backup Schedule Settings
Get Schedule Configuration
Update Schedule
"disabled": No automatic backups"daily": Once per day at 2 AM"weekly": Every Sunday at 2 AM"monthly": First day of month at 2 AM
backend/prisma/schema.prisma:661-673
Cloudinary Storage
Application-level backups are exported to Cloudinary:- Format: JSON
- Compression: Enabled for files > 1MB
- Access: Authenticated URLs with expiration
- Retention: Based on schedule settings (default 30 days)
Backup Verification
Before relying on any backup, verify its integrity:Check file size
Ensure the backup file is not empty or suspiciously small. A typical backup should be several MB.
Dependency Checking
Before deleting entities, check for dependencies:userunionunionMemberloanType
backend/src/controllers/backup.controller.ts:212-230
Backup Best Practices
Enable automatic backups - Set frequency to at least
"daily" with cloud storageTest restore procedures regularly - Schedule quarterly restore drills
Store backups off-site - Use Cloudinary (
"cloud") or "both" locationsDocument restore procedures - Keep runbooks updated with connection strings and commands
Monitor backup jobs - Check
BackupRecord status field for failuresVerify before major changes - Always create a manual backup before schema migrations or data transformations
Related Documentation
- Maintenance Mode - Lock system during restore
- Monitoring - Track backup job success
