Skip to content

mongoshield drill

Prove a backup restores: restore into a scratch deployment, check, clean up.

Terminal window
mongoshield drill [backup] [options]

Restores the backup into temporary databases on a scratch deployment, checks document counts and indexes (and, with --sample, documents byte for byte), runs your --assertions, then drops the temporary databases. Prints the RTO: how long the restore took. The result is recorded next to the backup.

ArgumentDescription
[backup]optionalBackup id, or "latest" (default)
OptionDescription
--target-uri <mongodb-uri>Scratch deployment to restore into (required, or MONGOSHIELD_DRILL_URI; never the configured source).
--sample <n>Documents per collection to compare byte for byte with the backup (time series: field by field). Default: 0.
--assertions <file>A .ts/.js file whose default export checks the restored data.
--keepKeep the temporary databases for inspection.
--prefix <prefix>Prefix of the temporary database names. Default: msdrill_.
--allow-same-deploymentAllow the target to be the backup's own source deployment.
--include <pattern>Only these namespaces, e.g. app.* or app.users. Repeatable.
--exclude <pattern>Skip these namespaces, e.g. *.audit_*. Repeatable.
--from <storage-url>Where backups are stored: ./dir, file:///abs, s3://bucket/prefix (default: config).
--identity-file <path>age identity file for encrypted backups (from mongoshield keygen). Repeatable.
--passphrase-env <VAR>Read the encryption passphrase from this environment variable.

The global options (--config, --json, --quiet, --verbose, --no-color, --yes) work here too.

Drill the latest backup into a scratch cluster:

Terminal window
mongoshield drill --target-uri $SCRATCH_URI --identity-file ~/keys/backup.key

Compare 100 random documents per collection and run your own checks:

Terminal window
mongoshield drill latest --target-uri $SCRATCH_URI --sample 100 --assertions ./drill.ts