Skip to content

mongoshield restore

Restore a backup into MongoDB.

Terminal window
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.

ArgumentDescription
[backup]optionalBackup id, or "latest" (default)
OptionDescription
--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.
--dropSame 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-runShow 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-indexesDo not create indexes (faster, for throwaway targets).
--skip-search-indexesDo not recreate Atlas Search / Vector Search indexes.
--verify-firstCheck every file's size and SHA-256 before writing anything (default when a target already has documents).
--no-verify-firstSkip 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.

Restore the latest backup next to the live data:

Terminal window
mongoshield restore --rename 'app.*=app_restored.*'

Preview restoring one collection into a staging cluster:

Terminal window
mongoshield restore 2026-10-20T03-00-04Z_7f3a9c --include app.users --to-uri $STAGING_URI --dry-run

Replace existing collections in a script:

Terminal window
mongoshield restore latest --drop --yes --identity-file ~/keys/backup.key

Restore an incremental's chain as it was at 03:17 (inside the chain):

Terminal window
mongoshield restore 2026-10-20T04-00-02Z_1a2b3c --at 2026-10-20T03:17:00Z --rename 'app.*=app_restored.*'