Skip to content

mongoshield import

Import mongodump output as a backup.

Terminal window
mongoshield import <path> [options]

Reads a directory written by mongodump --out or a file written by mongodump --archive (gzipped or not) and stores it as a regular MongoShield backup: compressed, optionally encrypted, with a manifest and checksums. Documents are copied byte for byte. Time-series buckets are unpacked into measurements, users and roles become the backup's users and roles, and the oplog of mongodump --oplog is replayed on restore (up to the end of the dump). System collections are not imported; they are listed as warnings.

ArgumentDescription
<path>requiredThe dump directory, the archive file, or "-" for an archive on stdin
OptionDescription
--to <storage-url>Where to store the backup: ./dir, file:///abs, s3://bucket/prefix.
--archiveThe path is a mongodump archive (detected automatically for files).
--gzipThe archive is gzipped (detected automatically when omitted).
--database <name>Database name when the path is one database's directory (default: its name).
--include <pattern>Only these namespaces, e.g. app.* or app.users. Repeatable.
--exclude <pattern>Skip these namespaces, e.g. *.audit_*. Repeatable.
--compression <zstd|gzip|none>Compression of the new backup. Default: zstd (gzip on Node.js without zstd).
--recipient <age1…>Encrypt for this age public key (from mongoshield keygen). Repeatable.
--passphrase-env <VAR>Read the encryption passphrase from this environment variable.
--label <key=value>Attach a label to the backup, e.g. env=prod. Repeatable.
--dumped-at <date>When the dump was taken, e.g. 2026-01-31T02:00:00Z (default: the files' time).
--ignore-oplogLeave out the oplog of a mongodump --oplog dump (consistency none).

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

Import a dump directory into local storage:

Terminal window
mongoshield import ./dump --to ./backups

Import a gzipped archive into S3, encrypted:

Terminal window
mongoshield import ./prod.archive.gz --to s3://acme-backups/prod --recipient age1…

Stream straight from mongodump:

Terminal window
mongodump --uri $URI --archive | mongoshield import - --archive --to ./backups