mongoshield find
Search a backup for documents, and restore just those.
mongoshield find [backup] <namespace> [filter] [options]Searches one collection of a backup with a MongoDB filter, without restoring it. The filter is Extended JSON: '{"_id":{"$oid":"…"}}', '{"age":{"$gte":18}}'. Supported: equality, $eq $ne $gt $gte $lt $lte $in $nin $exists $type $regex $and $or $nor $not $elemMatch $size. With --restore, the matching documents are written back (insert skips documents whose _id exists; upsert replaces them).
Arguments
Section titled “Arguments”| Argument | Description | |
|---|---|---|
[backup] | optional | Backup id, or "latest" (default) |
<namespace> | required | The collection to search, e.g. app.users |
[filter] | optional | MongoDB filter as Extended JSON (default: {}) |
Options
Section titled “Options”| Option | Description |
|---|---|
--from <storage-url> | Where backups are stored: ./dir, file:///abs, s3://bucket/prefix (default: config). |
--limit <n> | Stop after n matching documents (default: no limit). |
--projection <json> | Only these fields, e.g. '{"name":1,"email":1}' (or 0 to drop fields). |
--identity-file <path> | age identity file for encrypted backups (from mongoshield keygen). Repeatable. |
--passphrase-env <VAR> | Read the encryption passphrase from this environment variable. |
--restore | Write the matching documents to the target. |
--to-uri <mongodb-uri> | With --restore: the deployment to write to (default: the configured source). |
--to-namespace <db.collection> | With --restore: the collection to write to (default: the same namespace). |
--mode <insert|upsert> | With --restore: insert (skip existing _id) or upsert (replace them). Default: insert. |
--create | With --restore: create the target collection if it does not exist. |
--dry-run | With --restore: count what would be written, and write nothing. |
The global options (--config, --json, --quiet,
--verbose, --no-color, --yes) work here too.
Examples
Section titled “Examples”Find a user in the latest backup:
mongoshield find app.users '{"email":"ada@example.com"}'Find by ObjectId in a specific backup, as type-preserving JSON:
mongoshield find 2026-10-20T03-00-04Z_7f3a9c app.users '{"_id":{"$oid":"6523f1c2a1b2c3d4e5f60718"}}' --jsonPut back orders deleted by mistake (keeps the ones that still exist):
mongoshield find app.orders '{"customerId":42,"createdAt":{"$gte":{"$date":"2026-10-01T00:00:00Z"}}}' --restorePreview restoring into a side collection:
mongoshield find app.users '{"tags":"vip"}' --restore --to-namespace app.users_restored --create --dry-runMongoShield is MIT licensed and is not affiliated with, endorsed by or sponsored by MongoDB, Inc. MongoDB is a trademark of MongoDB, Inc.Privacy policy