Skip to content

mongoshield rehearse-upgrade

Prove a backup works on a newer MongoDB version before upgrading.

Terminal window
mongoshield rehearse-upgrade [backup] [options]

Checks the backup against MongoDB's compatibility notes for the target version (removed index types, removed JavaScript functions, the 8.0 null/undefined change, …), restores it into a server of that version, and runs the drill's checks plus validate, every view and every validator there. Without --target-uri an ephemeral mongod is started (needs the mongodb-memory-server package). The result is recorded next to the backup.

ArgumentDescription
[backup]optionalBackup id, or "latest" (default)
OptionDescription
--target-version <x.y[.z]>The MongoDB version to rehearse (required), e.g. 8.0 or 8.0.13.
--target-uri <mongodb-uri>Scratch deployment running the target version (default: an ephemeral mongod).
--mongod-binary <path>mongod binary for the ephemeral server, instead of downloading one.
--analyze-onlyOnly run the compatibility analysis (no server needed).
--sample <n>Documents per collection to compare byte for byte with the backup. Default: 100.
--assertions <file>A .ts/.js file whose default export checks the restored data.
--keepKeep the temporary databases (--target-uri only).
--prefix <prefix>Prefix of the temporary database names. Default: msdrill_.
--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.

Rehearse the latest backup on an ephemeral MongoDB 8.0.13:

Terminal window
mongoshield rehearse-upgrade --target-version 8.0.13

Rehearse on your own 8.0 staging cluster:

Terminal window
mongoshield rehearse-upgrade latest --target-version 8.0 --target-uri $STAGING_80_URI

Only check the compatibility notes, in CI, as JSON:

Terminal window
mongoshield rehearse-upgrade --target-version 8.0 --analyze-only --json