Migrating Data From One MongoHQ DB to Another
Create New DB in MongoHQ
First Things first you need to create the new database in MongoHQ that you are migrating your data to.
Export Data From Original DB
We will create a tmp folder to export the data into.
mkdir -p ~/tmp/mongodump
We will assume you created a database with the name fancy_pants and that MongoHQ assigned you to port 27043 on the server named temple. You will need to have a user setup on that database for authentication … lets assume my default username and password is set to admin and sekret respectively. We will use mongodump to export the data.
mongodump -h temple.mongohq.com:27043 -d fancy_pants -u admin -p sekret -o ~/tmp/mongodump
Import Data to New DB
We will assume you created a database with the name fancy_pants_staging and that MongoHQ assigned you to port 27021 on the server named hatch. You will need to have a user setup on that database for authentication … lets assume my default username and password is set to admin and sekret respectively. Now let’s use mongorestore to upload the data.
mongorestore -h hatch.mongohq.com:27021 -d fancy_pants_staging -u admin -p sekret ~/tmp/mongodump/fancy_pants