Migrate from MongoDB Atlas
TeselaDB
TeselaDB team
40 minIntermediate
Copy an Atlas database to your TeselaDB cluster with its search indexes and change the connection string.
Migrating from Atlas uses the same tools as from MongoDB: mongodump with the Atlas mongodb+srv string and
mongorestore against TeselaDB. What mongodump does not copy is the search indexes, so you note them first and create
them again at the end.
What you will build
The Atlas shop database copied into your TeselaDB cluster with its regular indexes and its search indexes, and at
the end your application pointing to the new cluster.
Requirements
- An Atlas user with read permission on the database and your machine's IP in the Atlas access list.
- A TeselaDB cluster, its CA (
pki/ca.pem) and a user with therestorerole. - The MongoDB Database Tools and
mongoshon a machine that reaches both Atlas and TeselaDB.
1. Note the search indexes
Open mongosh against Atlas and save the definition of each search index of each collection:
db.products.getSearchIndexes();2. Export from Atlas
mongodump --uri "mongodb+srv://user:<password>@cluster0.example.mongodb.net/shop" --gzip --archive=shop.gz3. Import into TeselaDB
mongorestore --uri "mongodb://root:<password>@node-01:27017/?tls=true&tlsCAFile=./ca.pem" --gzip --archive=shop.gzmongorestore creates the regular indexes. Atlas features that are not MongoDB ones, such as Atlas triggers, do not
travel in the archive.
4. Create the search indexes again
In mongosh on TeselaDB, create each search index again with the definition you noted in step 1, as the example below
does for the default index of products with dynamic mappings:
db.products.createSearchIndex("default", { mappings: { dynamic: true } });Try it
In TeselaDB, the counts and the indexes of each collection match those in Atlas, and a search returns results as soon
as its index has been built. Compare the count below with the one that countDocuments() gives in Atlas:
db.products.countDocuments();
db.products.aggregate([{ $search: { text: { query: "chair", path: { wildcard: "*" } } } }, { $limit: 3 }]);When everything matches, change your application's connection string to the TeselaDB cluster's one.
Clean up
Delete the export archive once the data is in TeselaDB, because it holds all your data unencrypted:
rm shop.gzNext steps
- Verify a migration, with sums and hashes per collection.
- Search indexes, with what each definition accepts.