mongoshield import
Import mongodump output as a backup.
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.
Arguments
Section titled “Arguments”| Argument | Description | |
|---|---|---|
<path> | required | The dump directory, the archive file, or "-" for an archive on stdin |
Options
Section titled “Options”| Option | Description |
|---|---|
--to <storage-url> | Where to store the backup: ./dir, file:///abs, s3://bucket/prefix. |
--archive | The path is a mongodump archive (detected automatically for files). |
--gzip | The 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-oplog | Leave out the oplog of a mongodump --oplog dump (consistency none). |
The global options (--config, --json, --quiet,
--verbose, --no-color, --yes) work here too.
Examples
Section titled “Examples”Import a dump directory into local storage:
mongoshield import ./dump --to ./backupsImport a gzipped archive into S3, encrypted:
mongoshield import ./prod.archive.gz --to s3://acme-backups/prod --recipient age1…Stream straight from mongodump:
mongodump --uri $URI --archive | mongoshield import - --archive --to ./backupsMongoShield is MIT licensed and is not affiliated with, endorsed by or sponsored by MongoDB, Inc. MongoDB is a trademark of MongoDB, Inc.Privacy policy