Skip to content

Instantly share code, notes, and snippets.

@jmd-mongo
Last active December 2, 2024 21:39
Show Gist options
  • Save jmd-mongo/63690ba41fcea86fcb8880902559b992 to your computer and use it in GitHub Desktop.
Save jmd-mongo/63690ba41fcea86fcb8880902559b992 to your computer and use it in GitHub Desktop.
mongorestore-nsExlude-nsInclude
# I've dumped a sharded cluster to the dump/ directory using mongodump.
#
# These examples specify --nsExclude="config.*" since otherwise mongorestore
# reports that you need to exclude 'config' or delete it prior to proceeding.
# When you exclude collections from production, trying to include a collection
# from that namespace results in no data being loaded.
➜ deployments mongorestore dump/ --nsExclude="config.*" --nsExclude="production.*" --nsInclude="production.records"
2024-12-02T16:34:08.852-0500 preparing collections to restore from
2024-12-02T16:34:08.853-0500 0 document(s) restored successfully. 0 document(s) failed to restore.
# Order does not matter. This has the same result.
➜ deployments mongorestore dump/ --nsExclude="config.*" --nsInclude="production.trips" --nsExclude="production.*"
2024-12-02T16:38:27.963-0500 preparing collections to restore from
2024-12-02T16:38:27.965-0500 0 document(s) restored successfully. 0 document(s) failed to restore.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment