Skip to content

Instantly share code, notes, and snippets.

@hoangdh
Last active February 19, 2024 14:04
Show Gist options
  • Save hoangdh/2fd1860c17b1dd75cbcdd2edc5961d4d to your computer and use it in GitHub Desktop.
Save hoangdh/2fd1860c17b1dd75cbcdd2edc5961d4d to your computer and use it in GitHub Desktop.
Migrate data MongoDB to another cluster without dumping to local disk

Migrate data MongoDB to another cluster

  • Source cluster: 10.10.10.10
  • Destination cluster: 10.10.20.10
mongodump --host 10.10.10.10 --port 27017 --archive --numParallelCollections=10 | \
mongorestore --host 10.10.20.10 --port 27017 --archive --numParallelCollections=10 --drop

Note: Use --gzip to save bandwidth.

mongodump --host 10.10.10.10 --port 27017 --archive --gzip --numParallelCollections=10 | \
mongorestore --host 10.10.20.10 --port 27017 --archive --gzip --numParallelCollections=10 --drop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment