Skip to content

Instantly share code, notes, and snippets.

@zeppelinen
Created June 11, 2021 14:59
Show Gist options
  • Save zeppelinen/bab5bd75f7f341f687209e7f0b4de74a to your computer and use it in GitHub Desktop.
Save zeppelinen/bab5bd75f7f341f687209e7f0b4de74a to your computer and use it in GitHub Desktop.
Pipe output from mongodump to mongorestore
#!/usr/bin/env bash
mongodump --host HOST:PORT --db SOURCE_DB --username USERNAME --password PASSWORD --archive \
| mongorestore --host HOST:PORT --nsFrom 'SOURCE_DB.*' --nsTo 'TARGET_DB.*' --username USERNAME --password PASSWORD --archive --drop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment