mongoshield export
Export a backup as mongodump output for mongorestore.
mongoshield export [backup] [options]Writes a backup as a mongodump directory (restore with mongorestore --dir) or archive (restore with mongorestore --archive), decrypted and checked. With --gzip the files are gzipped like mongodump --gzip (then restore with mongorestore --gzip). Time-series collections become mongorestore's bucket documents; users and roles are written for mongorestore --restoreDbUsersAndRoles.
Arguments
Section titled “Arguments”| Argument | Description | |
|---|---|---|
[backup] | optional | Backup id, or "latest" (default) |
Options
Section titled “Options”| Option | Description |
|---|---|
--format <directory|archive|jsonl|csv> | mongodump directory or archive, or one collection as JSON Lines or CSV. Default: directory. |
--output <path> | New directory or file; "-" writes an archive, JSONL or CSV to stdout. |
--namespace <db.collection> | With jsonl/csv: the collection to export. |
--fields <a,b.c> | With jsonl/csv: dotted field paths (required for csv: its columns). |
--filter <json> | With jsonl/csv: only documents matching this Extended JSON filter. |
--ejson <relaxed|canonical> | With jsonl/csv: Extended JSON flavour (canonical keeps every BSON type). Default: relaxed. |
--gzip | gzip the output, like mongodump --gzip. |
--from <storage-url> | Where backups are stored: ./dir, file:///abs, s3://bucket/prefix (default: config). |
--include <pattern> | Only these namespaces, e.g. app.* or app.users. Repeatable. |
--exclude <pattern> | Skip these namespaces, e.g. *.audit_*. Repeatable. |
--identity-file <path> | age identity file for encrypted backups (from mongoshield keygen). Repeatable. |
--passphrase-env <VAR> | Read the encryption passphrase from this environment variable. |
The global options (--config, --json, --quiet,
--verbose, --no-color, --yes) work here too.
Examples
Section titled “Examples”Export the latest backup to a directory for mongorestore:
mongoshield export --output ./dump && mongorestore --dir ./dumpExport one database of an encrypted backup as a gzipped archive:
mongoshield export latest --include 'app.*' --format archive --gzip --output app.archive.gz --identity-file ~/keys/backup.keyPipe straight into mongorestore:
mongoshield export --format archive --output - | mongorestore --uri $TARGET --archiveOne collection as CSV for a spreadsheet:
mongoshield export --format csv --namespace app.users --fields _id,name,address.city --output users.csvMongoShield is MIT licensed and is not affiliated with, endorsed by or sponsored by MongoDB, Inc. MongoDB is a trademark of MongoDB, Inc.Privacy policy