mongoshield restore-tenant
Restore one tenant's documents across every collection.
mongoshield restore-tenant [backup] [options]Restores only the documents that match a tenant filter, in every selected collection of a backup. Other tenants are not touched. Modes: insert (default) adds missing documents; upsert also replaces existing ones; replace-tenant deletes the tenant's current documents first, so it ends up exactly as backed up. A dry run is always shown first; replace-tenant asks for confirmation.
Arguments
Section titled “Arguments”| Argument | Description | |
|---|---|---|
[backup] | optional | Backup id, or "latest" (default) |
Options
Section titled “Options”| Option | Description |
|---|---|
--filter <json> | The tenant, as an Extended JSON filter, e.g. '{"tenantId":"acme"}'. |
--filter-for <ns=json> | A different filter for one collection, e.g. 'app.invoices={"org":"acme"}'. Repeatable. |
--mode <insert|upsert|replace-tenant> | insert, upsert, or replace-tenant (delete the tenant's documents first). Default: insert. |
--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.*=sandbox.*'. Repeatable. |
--dry-run | Show what would change, and 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. |
The global options (--config, --json, --quiet,
--verbose, --no-color, --yes) work here too.
Examples
Section titled “Examples”Preview restoring tenant acme from the latest backup:
mongoshield restore-tenant --filter '{"tenantId":"acme"}' --dry-runPut acme back exactly as it was in a given backup:
mongoshield restore-tenant 2026-10-20T03-00-04Z_7f3a9c --filter '{"tenantId":"acme"}' --mode replace-tenantRestore acme into a sandbox database to compare first:
mongoshield restore-tenant --filter '{"tenantId":"acme"}' --include 'app.*' --rename 'app.*=acme_check.*'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