Skip to content

mongoshield rollback

Roll the database back to a snapshot.

Terminal window
mongoshield rollback [label] [options]

Restores the newest snapshot with <label> over the live data, replacing each collection it contains, and drops the collections created after the snapshot in its databases (--keep-new keeps them). A safety snapshot (pre-rollback-<label>) of everything about to be replaced or dropped is taken first. Asks for confirmation unless --yes.

ArgumentDescription
[label]optionalSnapshot label (or use --id)
OptionDescription
--id <backup-id>Roll back to this backup id instead of a label.
--uri <mongodb-uri>The deployment to roll back (default: config source.uri).
--from <storage-url>Where backups are stored: ./dir, file:///abs, s3://bucket/prefix (default: config).
--include <pattern>Only these namespaces, e.g. app.* or app.users. Repeatable.
--exclude <pattern>Skip these namespaces, e.g. *.audit_*. Repeatable.
--mode <drop|upsert|insert|fail-if-exists>How to put collections back. Default: drop.
--dry-runShow the plan and stop; write nothing.
--keep-newKeep the collections created after the snapshot instead of dropping them.
--no-safety-snapshotDo not snapshot the live collections before replacing them.
--skip-erasuresDo not re-apply the GDPR erasure ledger afterwards.
--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.

Undo a failed migration:

Terminal window
mongoshield rollback v42-add-orders-index

Preview rolling back just one collection:

Terminal window
mongoshield rollback v42-add-orders-index --include app.orders --dry-run