Integrations

Backup Tool Integration

Backup Tool Integration

Use your database engine's native backup tools for scheduled backups. WhoDB is useful for inspecting data before or after backup and restore work.

PostgreSQL

Full logical backup:

Bash

pg_dump \
  --host "$PGHOST" \
  --port "${PGPORT:-5432}" \
  --username "$PGUSER" \
  --dbname "$PGDATABASE" \
  --format custom \
  --file "backup-${PGDATABASE}-$(date +%Y%m%d-%H%M%S).dump"

Restore into a test database:

Bash

createdb "$PGDATABASE_RESTORE"
pg_restore \
  --host "$PGHOST" \
  --port "${PGPORT:-5432}" \
  --username "$PGUSER" \
  --dbname "$PGDATABASE_RESTORE" \
  --clean \
  --if-exists \
  "backup-${PGDATABASE}.dump"

Verify row counts for a configurable schema:

Bash

#!/usr/bin/env bash
set -euo pipefail

SCHEMA_NAME="${SCHEMA_NAME:-public}"
DATABASE_NAME="${DATABASE_NAME:-$PGDATABASE}"

psql --dbname "$DATABASE_NAME" --tuples-only --no-align --set schema_name="$SCHEMA_NAME" <<'SQL'
SELECT table_schema, COUNT(*)
FROM information_schema.tables
WHERE table_schema = :'schema_name'
  AND table_type = 'BASE TABLE'
GROUP BY table_schema;
SQL

MySQL And MariaDB

Full logical backup:

Bash

mysqldump \
  --host "$MYSQL_HOST" \
  --port "${MYSQL_PORT:-3306}" \
  --user "$MYSQL_USER" \
  --password \
  --single-transaction \
  --routines \
  --triggers \
  "$MYSQL_DATABASE" \
  > "backup-${MYSQL_DATABASE}-$(date +%Y%m%d-%H%M%S).sql"

Restore into a test database:

Bash

mysql \
  --host "$MYSQL_HOST" \
  --port "${MYSQL_PORT:-3306}" \
  --user "$MYSQL_USER" \
  --password \
  "$MYSQL_RESTORE_DATABASE" \
  < backup.sql

SQLite

Use SQLite's online backup command when possible:

Bash

sqlite3 production.db ".backup 'backup-$(date +%Y%m%d-%H%M%S).db'"

For offline databases, copying the file is acceptable only when no process is writing to it.

MongoDB

Use mongodump and mongorestore:

Bash

mongodump \
  --uri "$MONGODB_URI" \
  --archive="backup-$(date +%Y%m%d-%H%M%S).archive" \
  --gzip

Bash

mongorestore \
  --uri "$MONGODB_RESTORE_URI" \
  --archive="backup.archive" \
  --gzip

Retention

Example retention cleanup:

Bash

find "$BACKUP_DIR" -type f -mtime +"${RETENTION_DAYS:-30}" -delete

Checksums

Record checksums after backup creation:

Bash

sha256sum backup-file > backup-file.sha256

Verify later:

Bash

sha256sum -c backup-file.sha256

Scheduling

Use your platform scheduler:

  • cron or systemd timers on a VM.
  • Kubernetes CronJob.
  • Managed backup jobs from your cloud/database provider.
  • CI/CD scheduled workflows only for non-production or carefully controlled environments.

Using WhoDB In The Backup Workflow

WhoDB is useful for backup-adjacent checks:

  • Inspect table counts and recent records before a backup.
  • Run validation queries in Scratchpad.
  • Inspect restored test databases.
  • Compare source and restored rows with read-only queries.

Example validation query:

sql

SELECT COUNT(*) AS total_rows
FROM users;
Data Migration

Use validation queries when moving data.

Troubleshooting

Debug database connectivity before backup jobs.