From MongoDB

Copy a MongoDB database to TeselaDB with mongodump and mongorestore.

Copy a MongoDB database to TeselaDB with mongodump and mongorestore, the MongoDB database tools.

Requirements

  • A running TeselaDB cluster and its CA, pki/ca.pem.
  • A user with the restore role in TeselaDB.
  • The MongoDB Database Tools on a machine that sees both.

Export from MongoDB

Shell
mongodump --uri "mongodb://user:<password>@mongo-01:27017/shop" --gzip --archive=shop.gz

To avoid stopping writes, export the whole replica set with --oplog, which also saves the operations that arrive while the copy runs so that mongorestore applies them at the end.

Import into TeselaDB

Shell
mongorestore --uri "mongodb://root:<password>@node-01:27017/?tls=true&tlsCAFile=./ca.pem" --gzip --archive=shop.gz

With an archive made with --oplog, add --oplogReplay. mongorestore also creates the indexes.

Check

The counts and indexes of each collection match MongoDB's, as in Verify the migrated data.

Common problems

  • mongorestore fails with Unauthorized (13) because the user lacks the restore role.
  • The connection to TeselaDB closes because tls=true is missing from the string.

See also