How to Migrate your MongoDB Database to Galaxy MongoDB Hosting
Migrating a database can be quite a challenge, right?
At Galaxy, we truly understand how stressful technical tasks can be and are here to make things easier for you. Hence, we created this follow-up article to facilitate your first MongoDB database migration to our Galaxy cloud. These steps are recommended for databases up to 15GB in size and unsuitable for MongoDB clusters in sharded mode.
Please note that this procedure will have downtime. If you need to migrate a larger database or complex structure without downtime, please contact our specialists via our support chat.
Get your environment ready!
To complete this tutorial, we only need Docker, as it runs the container for all migration steps installed.
Step 1: Set Up Docker
Why Docker?
Docker simplifies migrations by running pre-configured containers, avoiding manual installations and dependencies.
Install Docker:
Download and install Docker from docker.com. It’s quick and supports all major operating systems.
Step 2: Prepare Database Details
Make sure you have your connection strings from your source and destination databases. This example shows a connection string for Galaxy hosting:
mongodb://admin:passwordEncodedb@user_testcluster-01.mongodb.galaxy-cloud.io:30010,user_testcluster-02.mongodb.galaxy-cloud.io:30010,user_testcluster-03.mongodb.galaxy-cloud.io:30010/admin?replicaSet=test_replicaset
Step 3: Stop your application
We don’t want inconsistent data, right?
So, at this step, we need to stop our application so that it does not write any data to our database. After a complete stop, we can proceed with the migration.
When ready, start the migration process by executing the following command:
docker run - rm –name mongo-migration-tool -d
-e SOURCE_URI=""
-e TARGET_URI=""
-e DB_NAME="example_db_name"
meteor/galaxy-mongodb-migrate:202409101534
This will start a container that will dump the source database and restore this dump in the destination database.
You can verify if the container is running by executing the command:
# docker ps | grep mongo-migration-tool
Also, you can verify the backup progress by examining the logs of this container with the command:
# docker logs mongo-migration-tool
Step 4: Verify and Secure
After it is complete, the container is stopped and removed. You can now see all the data on your destination database.
Inspect the Data:
Use tools like MongoDB Compass to confirm successful migration.
Create New Users:
Enhance security by creating dedicated database users in Galaxy.
Limitations and Recommendations
Database Size: For databases over 15GB, alternative methods may be more effective.
Sharded Mode: This process does not support sharded MongoDB configurations.
Step 5: Configure your application to your new connection string
After a successful migration, you can change your app’s configuration and restart it to use the data in your database located on our Galaxy MongoDB hosting.
Wrapping Up
Migrating your MongoDB database to Galaxy Hosting is an essential step in leveraging the full potential of our reliable and scalable cloud platform.
Remember, this guide is tailored for databases up to 15GB and non-sharded configurations. If your requirements fall outside these parameters or you prefer a migration with no downtime, don’t hesitate to contact our support team using the chat button on your Galaxy account. We’re here to assist you every step of the way. Also, you can review the official Galaxy documentation for more information.
If you haven’t created a Galaxy account yet, now’s the perfect time to do so and you can test it out with a free plan! It allows you to effortlessly host a variety of applications, including Node and Meteor, with even more options coming soon. Don’t miss out on this opportunity, create your account now!!
Happy migrating!
How to Migrate your MongoDB Database to Galaxy MongoDB Hosting was originally published in Meteor Blog on Medium, where people are continuing the conversation by highlighting and responding to this story.
Source: Read MoreÂ