mongoshield restore
Restore a backup into MongoDB.
mongoshield restore [backup] [options]Shows the plan first, then restores. By default nothing is overwritten: the restore stops if a target collection already has documents. Use --rename to restore next to the live data, or --mode to replace (drop), add to (insert) or merge into (upsert) existing collections; those modes ask for confirmation.
Arguments
Section titled “Arguments”| Argument | Description | |
|---|---|---|
[backup] | optional | Backup id, or "latest" (default) |
Options
Section titled “Options”| Option | Description |
|---|---|
--to-uri <mongodb-uri> | Restore into this deployment (default: the configured source). |
--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. |
--rename <from=to> | Restore under another name, e.g. 'app.*=app_restored.*'. Repeatable. |
--mode <fail-if-exists|drop|insert|upsert> | What to do when a target collection already exists. Default: fail-if-exists. |
--drop | Same as --mode drop. |
--at <time> | Point-in-time recovery: an ISO date (2026-11-14T03:17:42Z) or a cluster time (t:i). Needs the change journal, or an incremental chain reaching that time. |
--source-cluster <clusterId[/instanceId]> | With --at: use base backups of this deployment (as mongoshield inspect shows its source). Default: the configured source's. |
--dry-run | Show the plan and stop; write nothing. |
--identity-file <path> | age identity file for encrypted backups (from mongoshield keygen). Repeatable. |
--passphrase-env <VAR> | Read the encryption passphrase from this environment variable. |
--skip-indexes | Do not create indexes (faster, for throwaway targets). |
--skip-search-indexes | Do not recreate Atlas Search / Vector Search indexes. |
--verify-first | Check every file's size and SHA-256 before writing anything (default when a target already has documents). |
--no-verify-first | Skip that check even when targets already have documents. |
--users-and-roles <skip|create|replace> | Restore the backup's users and roles: create missing ones, or replace existing ones too. Default: skip. |
The global options (--config, --json, --quiet,
--verbose, --no-color, --yes) work here too.
Examples
Section titled “Examples”Restore the latest backup next to the live data:
mongoshield restore --rename 'app.*=app_restored.*'Preview restoring one collection into a staging cluster:
mongoshield restore 2026-10-20T03-00-04Z_7f3a9c --include app.users --to-uri $STAGING_URI --dry-runReplace existing collections in a script:
mongoshield restore latest --drop --yes --identity-file ~/keys/backup.keyRestore an incremental's chain as it was at 03:17 (inside the chain):
mongoshield restore 2026-10-20T04-00-02Z_1a2b3c --at 2026-10-20T03:17:00Z --rename 'app.*=app_restored.*'MongoShield is MIT licensed and is not affiliated with, endorsed by or sponsored by MongoDB, Inc. MongoDB is a trademark of MongoDB, Inc.Privacy policy