Skip to content

mongoshield pull

Copy production data into a local MongoDB, masked.

Terminal window
mongoshield pull [options]

Like copy, with safe defaults for local development: the target defaults to mongodb://localhost:27017 and must be on this machine, and a --mask file is required (--no-mask --yes copies raw data, deliberately). Add --subset for a smaller slice.

OptionDescription
--from <mongodb-uri>Copy from this deployment (default: the configured source / MONGODB_URI).
--include <pattern>Only these namespaces, e.g. app.* or app.users. Repeatable.
--exclude <pattern>Skip these namespaces, e.g. *.audit_*. Repeatable.
--rename <from=to>Copy under another name, e.g. 'app.*=app_staging.*'. Repeatable.
--mask <file>Mask file (e.g. ./mask.ts) applied to every document on its way.
--mask-secret-env <VAR>Read the masking secret from this variable when the mask file sets none. Default: MONGOSHIELD_MASK_SECRET.
--subset <file>Subset file (e.g. ./subset.ts): filters, and references to follow.
--mode <fail-if-exists|drop|insert|upsert>What to do when a target collection already exists. Default: fail-if-exists.
--dropSame as --mode drop.
--dry-runShow the plan and stop; write nothing.
--parallelism <n>Collections copied at the same time (1–64). Default: 4.
--skip-indexesDo not create indexes (faster, for throwaway targets).
--skip-search-indexesDo not recreate Atlas Search / Vector Search indexes on the target.
--resumeContinue an interrupted copy from its checkpoint (same options as before).
--checkpoint <file>Where the copy records its progress for --resume. Default: .mongoshield/copy-<id>.json.
--to <mongodb-uri>Copy into this local deployment. Default: mongodb://localhost:27017.
--no-maskCopy without masking (needs --yes; the data stays as sensitive as production).
--allow-remote-targetAllow a --to that is not on this machine.

The global options (--config, --json, --quiet, --verbose, --no-color, --yes) work here too.

Pull a masked copy of the app database to the local MongoDB:

Terminal window
mongoshield pull --from $PROD_URI --include 'app.*' --mask ./mask.ts

Refresh a masked, recent slice, replacing yesterday's:

Terminal window
mongoshield pull --mask ./mask.ts --subset ./subset.ts --drop --yes