Skip to main content

CODITECT Context Database Backup Script

======================================= Backs up context.db and unified_messages.jsonl to GCP Cloud Storage with timestamped folders and retention management. FEATURES:

  • SQLite snapshot for consistent database backups (even during active use)
  • Gzip compression (~75% size reduction, faster uploads)
  • Safe for parallel sessions - no file locking issues USAGE: ./scripts/backup-context-db.sh # Full backup ./scripts/backup-context-db.sh --dry-run # Preview only ./scripts/backup-context-db.sh --status # Check backup status ./scripts/backup-context-db.sh --restore TIMESTAMP # Restore from backup ./scripts/backup-context-db.sh --sync # Full sync: backup, pull, merge ./scripts/backup-context-db.sh --pull # Download latest from GCS ./scripts/backup-context-db.sh --merge # Merge downloaded DB into local ./scripts/backup-context-db.sh --litestream # Use Litestream for real-time sync MULTI-MACHINE SYNC (Recommended): For real-time continuous replication, use Litestream sidecar: ./scripts/litestream-sidecar.sh start REQUIREMENTS:
  • gcloud CLI installed and authenticated
  • gsutil available
  • sqlite3 (for database snapshots) FIRST-TIME SETUP:
  1. Run: ./scripts/backup-context-db.sh --setup
  2. This creates the GCP bucket if it doesn't exist

File: backup-context-db.sh

Type: Shell Script

Usage

bash backup-context-db.sh
# or
./backup-context-db.sh