DEV Community

Cover image for How to migrate Database and Collections Efficiently with Studio 3T
Vesi Staneva for SashiDo.io

Posted on • Originally published at blog.sashido.io

How to migrate Database and Collections Efficiently with Studio 3T

One of the great benefits that SashiDo gives you is full access to your database. You can not only explore your records from our super-user-friendly DB Browser but go further and connect directly to your MongoDB with a tool of your choice.

We already have introduced you to Studio 3T - an easily operated, quite fast and very well documented MongoDB client, in our YouTube video tutorial series. There we presented a demo on how to import and export collections to JSON.

Nevertheless, we often get many questions on how to migrate to SashiDo and today, I will shed more light on how you can easily migrate your data with Studio 3T. The best solution for export/import data when it comes to migration will be in BSON, as MongoDB represents JSON documents in binary-encoded format behind the scenes.

I will guide you step by step through the process, but first, let me share why Studio 3T:

Studio 3T is a fully-featured IDE for MongoDB that allows users to explore their local database or to work with shards and replica sets. It is fully compatible with current and legacy releases of MongoDB and has a set of useful features for interacting with the database, including SQL queries. Customers are granted a free trial period of 30 days and discounts are available for Students, Teachers, Nonprofit Organizations and Startups. :)

On top of that, we have arranged a discount for all SashiDo customers, as we want you to have the most convenient and easy way of interacting with your database. Just contact Angelo from Studio 3T and pass on SD0619 promo code and you’ll get 20% off. How cool is that?! You can download Studio 3T from here.

Now, when we know our tool, let’s start off by connecting to your SashiDo MongoDB!

Connect to your SashiDo DB

The Studio 3T Connection Manager enables you to link to your MongoDB almost instantly. There are several options that you can use to start a connection, but for the purposes of this tutorial, I'll focus on using the MongoDB URI. The URL for your SashiDo Database can be found on the App's Dashboard -> App Settings -> Security&Key. Just click on Show Database URL and copy the address.

DB_URI

Next, open Studio 3T and press the Connect button in the global toolbar. This will open the Connection Manager. Click on New Connection to launch the New Connection Window. It would display several options for you to choose from. Select from URI and paste the already copied connection string. Confirm with the OK button.

Last but not least, give the new Connection an easily recognizable name and hit Save. The DB is now displayed in the Connection Manager and all that’s left is to press Connect

connectDbFinal

The cool thing is that Studio 3T will remember that connection and automatically save it, so next time you will connect with just one click!

Once you are connected, you can start exploring all great features that Studio 3T offers - Visual Query Builder, SQL Queries, In-place Data Editing, Tasks, and many more neat options. In this tutorial, we will use the Import and Export properties, which enable you to migrate data in a specified format. All JSON, CSV, BSON, and SQL are supported, together with import/export to Another Collection.

Export to BSON(mongodump)

  1. First open the Export Wizard! There are two ways to do that:
  • Press on Export in the Global Toolbar.

  • Right-click on any server, database, or the collection and choose Export Data.

  1. Select Export Format. We will choose mongodump for our migration example, as this is the binary format to export a database/collection together with the indexing rules, hence is most suitable for migrations.

dumpFinal

On the next screen select BSON - mongodump folder.

dump2

  1. Pick out the folder to which the data will be exported. Move on by selecting the folder where you will export the DB. Have in mind that mongodump folders have a specific structure. This means that Studio 3T will automatically create a subfolder with the dumped database within the chosen folder, which will have the existing DB name. If you want to import this database at a later stage, you will need to rename the subfolder with the new database name.

  2. Smash the Start Export button and wait a few seconds or minutes, depending on the database size. See how straightforward the whole process is:

exportFinale

Let’s move on and see how easy is to import data. :)

Import from BSON(mongorestore)

Well, the process here is quite similar to the one we have already gone through.

  1. Connect to the new Database, where you will import the previously exported data and get its name. You will need the name to rename the subfolder of the already dumped Database, remember?

copyName

  1. Rename the already existing mongodump subfolder respectively.

  2. Open the Import Wizard - using the below approaches, analogous to the Export one:

  • Right Click on the specific collection/database and Choose Import Collections
  • From the Global Toolbar -> Import
  1. Choose BSON - mongodump folder for Import Option and hit OK.

Then from the Select mongodump folder to import field choose the root folder of the dumped database. All collections that are about to be imported will display on the right side of the screen.

  1. Start the import of collections by simply clicking the Execute button.

ImportGoodQlty

It’s simple as that! See for yourself how easy and flawless you can import a Database with Studio 3T:

importFinale

Voilà! The Import is completed and you can play around with your Database directly from your super-user-friendly SashiDo DB Browser, which makes every task a piece of cake.

N.B! If you are a Windows user, note that Windows has a specific general naming convention and character limitations, which in some cases can be in controversy with the MongoDB naming system. In that line of thinking, pay attention to databases that have columns of type Pointer or Relation as these may not be properly exported/imported. Another tricky case while using Studio 3T is that mongodump creates BSON archives in .gzip, which is incompatible with Windows.

Happy coding!

Top comments (0)