Skip to content

CLI reference

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

CommandWhat it does
backupBack up MongoDB to storage
restoreRestore a backup into MongoDB
snapshotBack up under a name before a migration
rollbackRoll the database back to a snapshot
findSearch a backup for documents, and restore just those
restore-tenantRestore one tenant's documents across every collection
historyShow how one document changed across backups and the journal
diffCompare two backups, or a backup with the live database
copyCopy databases between deployments, with masking and subsetting
pullCopy production data into a local MongoDB, masked
maskFind personal data and suggest mask rules for copy/pull (suggest)
listList backups in storage
inspectShow the details of one backup
verifyCheck that a backup is complete and intact
drillProve a backup restores: restore into a scratch deployment, check, clean up
rehearse-upgradeProve a backup works on a newer MongoDB version before upgrading
importImport mongodump output as a backup
exportExport a backup as mongodump output for mongorestore
pruneDelete backups that the retention policy no longer keeps
replicateCopy backups to another storage location (3-2-1)
rekeyAdd or remove the keys that can decrypt existing backups
runRun the scheduled job once: lock, back up, verify, prune, notify
scheduleRun backups on the configured cron schedule (long-running)
journalRecord every change for point-in-time recovery (start | status)
holdProtect a backup from pruning
releaseRemove a hold so the backup can be pruned again
deleteDelete one backup by id (refuses held, locked or depended-on backups)
eraseRecord a GDPR erasure so restores never bring the data back
erasuresList the GDPR erasure ledger, or apply it to a database
keygenGenerate an age key pair for encrypted backups
initCreate mongoshield.config.ts (interactive)
loginSign in to Google Drive or Dropbox and get the token for backups
versionPrint the MongoShield version

Accepted by every command.

OptionDescription
-c, --config <path>Config file (default: mongoshield.config.ts and friends in the current directory).
--jsonPrint one machine-readable JSON document on stdout.
-q, --quietOnly print results, warnings and errors.
--verbosePrint debug logs, and stack traces on errors.
--no-colorDisable colors (also: NO_COLOR=1).
-y, --yesAnswer yes to confirmations (for scripts).
-h, --helpShow help.

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.