Skip to content

mongoshield restore-tenant

Restore one tenant's documents across every collection.

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

ArgumentDescription
[backup]optionalBackup id, or "latest" (default)
OptionDescription
--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-runShow 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.

Preview restoring tenant acme from the latest backup:

Terminal window
mongoshield restore-tenant --filter '{"tenantId":"acme"}' --dry-run

Put acme back exactly as it was in a given backup:

Terminal window
mongoshield restore-tenant 2026-10-20T03-00-04Z_7f3a9c --filter '{"tenantId":"acme"}' --mode replace-tenant

Restore acme into a sandbox database to compare first:

Terminal window
mongoshield restore-tenant --filter '{"tenantId":"acme"}' --include 'app.*' --rename 'app.*=acme_check.*'