Skip to content

mongoshield snapshot

Back up under a name before a migration.

Terminal window
mongoshield snapshot <label> [options]

Takes a consistent backup labelled with <label>, to roll back to with mongoshield rollback <label> if the migration goes wrong. It is an ordinary backup: list, verify, hold and prune treat it like any other.

ArgumentDescription
<label>requiredA name for this point, e.g. v42-add-index
OptionDescription
--uri <mongodb-uri>Connection string (default: config source.uri, MONGOSHIELD_URI or MONGODB_URI).
--to <storage-url>Where to store the snapshot (default: config storage).
--include <pattern>Only these namespaces, e.g. app.* or app.users. Repeatable.
--exclude <pattern>Skip these namespaces, e.g. *.audit_*. Repeatable.
--label <key=value>Attach another label, e.g. migration=20261021-add-index. Repeatable.
--retain-days <days>Make the snapshot write-once for this many days (object lock storage).

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

Snapshot the app database before migrating:

Terminal window
mongoshield snapshot v42-add-orders-index --include 'app.*'