CLI reference
mongoshield <command> [options]Configuration is read from mongoshield.config.ts (see the
config file reference), MONGOSHIELD_* environment variables
and flags, in increasing order of precedence. Every command prints its own help with
mongoshield <command> --help; these pages are generated from the same definitions.
Commands
Section titled “Commands”| Command | What it does |
|---|---|
backup | Back up MongoDB to storage |
restore | Restore a backup into MongoDB |
snapshot | Back up under a name before a migration |
rollback | Roll the database back to a snapshot |
find | Search a backup for documents, and restore just those |
restore-tenant | Restore one tenant's documents across every collection |
history | Show how one document changed across backups and the journal |
diff | Compare two backups, or a backup with the live database |
copy | Copy databases between deployments, with masking and subsetting |
pull | Copy production data into a local MongoDB, masked |
mask | Find personal data and suggest mask rules for copy/pull (suggest) |
list | List backups in storage |
inspect | Show the details of one backup |
verify | Check that a backup is complete and intact |
drill | Prove a backup restores: restore into a scratch deployment, check, clean up |
rehearse-upgrade | Prove a backup works on a newer MongoDB version before upgrading |
import | Import mongodump output as a backup |
export | Export a backup as mongodump output for mongorestore |
prune | Delete backups that the retention policy no longer keeps |
replicate | Copy backups to another storage location (3-2-1) |
rekey | Add or remove the keys that can decrypt existing backups |
run | Run the scheduled job once: lock, back up, verify, prune, notify |
schedule | Run backups on the configured cron schedule (long-running) |
journal | Record every change for point-in-time recovery (start | status) |
hold | Protect a backup from pruning |
release | Remove a hold so the backup can be pruned again |
delete | Delete one backup by id (refuses held, locked or depended-on backups) |
erase | Record a GDPR erasure so restores never bring the data back |
erasures | List the GDPR erasure ledger, or apply it to a database |
keygen | Generate an age key pair for encrypted backups |
init | Create mongoshield.config.ts (interactive) |
login | Sign in to Google Drive or Dropbox and get the token for backups |
version | Print the MongoShield version |
Global options
Section titled “Global options”Accepted by every command.
| Option | Description |
|---|---|
-c, --config <path> | Config file (default: mongoshield.config.ts and friends in the current directory). |
--json | Print one machine-readable JSON document on stdout. |
-q, --quiet | Only print results, warnings and errors. |
--verbose | Print debug logs, and stack traces on errors. |
--no-color | Disable colors (also: NO_COLOR=1). |
-y, --yes | Answer yes to confirmations (for scripts). |
-h, --help | Show help. |
Exit codes
Section titled “Exit codes”0 means success. Failures exit with a code that depends on the kind of error;
see Error codes for the full list and what to do about each.
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