Skip to content

mongoshield diff

Compare two backups, or a backup with the live database.

Terminal window
mongoshield diff <backupA> [backupB] [options]

Compares every collection of two backups (or a backup and a live deployment): documents added, removed and changed (matched by _id), and differences in indexes and collection options. With one backup, it is compared with the latest.

ArgumentDescription
<backupA>requiredThe older backup: an id or "latest"
[backupB]optionalThe newer backup (default: latest)
OptionDescription
--live <mongodb-uri>Compare with this live deployment instead of a second backup.
--detailsShow example _ids and the differing indexes and options.
--examples <n>With --details: example _ids per category. Default: 10.
--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.
--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.

What changed since a given backup:

Terminal window
mongoshield diff 2026-10-20T03-00-04Z_7f3a9c

How far the live database has drifted from the latest backup:

Terminal window
mongoshield diff latest --live "$MONGODB_URI" --details