Skip to content

Backup System

Keshless uses an automated backup system powered by GCP Cloud Scheduler to ensure data integrity and enable disaster recovery.

Backup Schedule

JobScheduleTime (UTC)Description
PostgreSQL Daily0 2 * * *Daily 2:00 AMFull database export
PostgreSQL Monthly0 2 1 * *1st of month 2:00 AMLong-term retention backup
Secrets Backup0 4 * * 0Sundays 4:00 AMEncrypted config backup
Cleanup0 5 * * 1Mondays 5:00 AMRemove expired backups

PostgreSQL Backups

What's Backed Up

The full PostgreSQL database is exported as a compressed SQL dump file.

Critical Tables:

CategoryTables
Usersusers, vendors, vendorsubusers, wallets
Transactionswallettransactions, transactions
Accountingjournalentries, ledgerentries, accountbalances
Compliancealerts, customerriskprofiles, sars
Configurationnfccards, feeconfigs, transactionlimitconfigs
Auditauditlog (hash-chained for integrity)

Storage Structure

All backups are stored in GCP Cloud Storage (europe-west1):

PathContents
gs://keshless-backups/postgresql/daily/{date}/Daily backup + manifest
gs://keshless-backups/postgresql/monthly/{month}/Monthly backup + manifest

Manifest File

Each backup includes a manifest.json with metadata:

FieldDescription
backupTypedaily or monthly
timestampBackup creation time
databaseDatabase name
filenameBackup file name
sizeBytesUncompressed size
compressedBytesCompressed size
durationMsBackup duration
tablesArray of table row counts

Document Storage

GCP Cloud Storage Structure

BucketFolderContents
keshless-documentskyc/KYC documents (ID cards)
keshless-documentsselfies/User selfies
keshless-documentsvendor-kyc/Vendor verification docs
keshless-documentsvendor-media/Vendor logos/media

Security

FeatureDescription
Private bucketsNo public access (--public-access-prevention)
Signed URLsTime-limited access (15-minute expiry for KYC)
Encryption at restAES-256 (Google-managed keys)
Audit loggingAll document access is logged

Secrets Backup

What's Backed Up

CategoryContents
Cloud Run Env VarsAll env vars from keshless-api service
Sensitive VariablesDATABASE_URL, JWT_SECRET, JWT_REFRESH_SECRET, API keys

Encryption

PropertyValue
AlgorithmAES-256-GCM
Key DerivationSHA-256 hash of SECRETS_ENCRYPTION_KEY
IVRandom 16-byte per backup
IntegrityAuth tag verification

CRITICAL: Store SECRETS_ENCRYPTION_KEY in a password manager. Without it, backups cannot be decrypted.

Storage Location

PathContents
gs://keshless-backups/secrets/weekly/{date}.json.encryptedWeekly encrypted backup
gs://keshless-backups/secrets/latest.json.encryptedMost recent backup

Retention Policy

Backup TypeRetention Period
PostgreSQL Daily2 years (730 days)
PostgreSQL Monthly5 years (1825 days)
Secrets Weekly2 years (730 days)

The cleanup job runs weekly to remove expired backups.

Cloud Scheduler Jobs

Job Configuration

Job NameURI PathSchedule
keshless-backup-postgres-daily-{env}/backup-jobs/postgres0 2 * * *
keshless-backup-postgres-monthly-{env}/backup-jobs/postgres-monthly0 2 1 * *
keshless-backup-secrets-weekly-{env}/backup-jobs/secrets0 4 * * 0
keshless-backup-cleanup-weekly-{env}/backup-jobs/cleanup0 5 * * 1

Required Headers

HeaderValue
X-Job-SecretEnvironment-specific job secret
Content-Typeapplication/json

API Endpoints

EnvironmentBase URL
Productionhttps://api.keshless.app
Developmenthttps://keshless-api-dev-659214682765.europe-west1.run.app

Manual Testing

Test backup endpoints with:

bash
curl -X POST \
  -H "X-Job-Secret: your-job-secret" \
  -H "Content-Type: application/json" \
  https://{api-url}/backup-jobs/{job-name}
Job NameDescription
postgresDaily PostgreSQL backup
postgres-monthlyMonthly PostgreSQL backup
secretsSecrets backup
cleanupOld backup cleanup

Monitoring

Verification Steps

StepMethod
View job historyCloud Scheduler > Jobs > View Logs
Check backup filesCloud Storage > keshless-backups bucket
List via CLIgcloud storage ls gs://keshless-backups/postgresql/daily/
Check total sizegcloud storage du gs://keshless-backups/ --summarize
AlertCondition
Job failuresAny job execution failure
Missing backupsNo new files for 2+ days
Unusual sizesSignificant deviation from normal

Internal use only - Keshless Payment Platform