Skip to content

Instantly share code, notes, and snippets.

@bcmarinacci
Created March 24, 2019 01:20
Show Gist options
  • Select an option

  • Save bcmarinacci/9ac005b1655c45bd9f22c29ce918052f to your computer and use it in GitHub Desktop.

Select an option

Save bcmarinacci/9ac005b1655c45bd9f22c29ce918052f to your computer and use it in GitHub Desktop.
Pipe mongodump into mongorestore
mongodump \
--host "${ORIGIN_HOST}" \
--db "${ORIGIN_DB}" \
--username "${ORIGIN_USERNAME}" \
--password "${ORIGIN_PASSWORD}" \
--authenticationDatabase 'admin' \
--collection "${COLLECTION}" \
-vvv \
--gzip \
--archive |
mongorestore \
--host "${TARGET_HOST}" \
--db "${TARGET_DB}" \
--username "${TARGET_USERNAME}" \
--password "${TARGET_PASSWORD}" \
--authenticationDatabase 'admin' \
--nsInclude "${ORIGIN_DB}.${COLLECTION}" \
--nsFrom "${ORIGIN_DB}.${COLLECTION}" \
--nsTo "${TARGET_DB}.${COLLECTION}" \
--drop \
--objcheck \
--stopOnError \
-vvv \
--gzip \
--archive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment