Search code examples
mongodbmigrationdumpmongodb-atlas

How to back and restore Mongodb dump from local to mongodb atlasCloud?


what is the best way to migrate MongoDB database from local to Cloud MongoDB Atlas cluster?


Solution

  • Create ecom database dump from the mongodb local system

    C:\Program Files\MongoDB\Server\4.0\bin>mongodump -d ecom -o D:\per\test\dump
    2021-11-23T22:44:23.483+0530    writing ecom.words to
    2021-11-23T22:44:23.485+0530    writing ecom.wishlists to
    2021-11-23T22:44:23.487+0530    writing ecom.carts to
    2021-11-23T22:44:23.488+0530    writing ecom.products to
    2021-11-23T22:44:23.602+0530    done dumping ecom.words (23 documents)
    2021-11-23T22:44:23.602+0530    writing ecom.orders to
    2021-11-23T22:44:23.634+0530    done dumping ecom.wishlists (15 documents)
    2021-11-23T22:44:23.635+0530    writing ecom.reviews to
    2021-11-23T22:44:23.730+0530    done dumping ecom.orders (11 documents)
    2021-11-23T22:44:23.730+0530    writing ecom.categories to
    2021-11-23T22:44:23.751+0530    done dumping ecom.reviews (7 documents)
    2021-11-23T22:44:23.751+0530    writing ecom.users to
    2021-11-23T22:44:23.778+0530    done dumping ecom.users (4 documents)
    2021-11-23T22:44:23.779+0530    writing ecom.addresses to
    2021-11-23T22:44:23.806+0530    done dumping ecom.categories (4 documents)
    2021-11-23T22:44:23.806+0530    writing ecom.brands to
    2021-11-23T22:44:23.884+0530    done dumping ecom.addresses (2 documents)
    2021-11-23T22:44:23.884+0530    writing ecom.merchants to
    2021-11-23T22:44:23.914+0530    done dumping ecom.brands (2 documents)
    2021-11-23T22:44:24.057+0530    done dumping ecom.merchants (1 document)
    2021-11-23T22:44:25.568+0530    done dumping ecom.carts (12 documents)
    2021-11-23T22:44:25.589+0530    done dumping ecom.products (16 documents)
    

    Restoring ecom database dump to Cloud Atlas mern-store-80201 database:

    Karthikeyan.Anbalaga@KAAN-BLR-02 MINGW64 /d/per/test
    $ '/c/Program Files/MongoDB/Server/4.0/bin/mongorestore' --uri mongodb+srv://admin:[email protected]/mern-store-80201
    2021-11-23T23:32:59.871+0530    using default 'dump' directory
    2021-11-23T23:32:59.873+0530    preparing collections to restore from
    2021-11-23T23:33:00.033+0530    reading metadata for MERN-STORE-80201.carts from dump\MERN-STORE-80201\carts.metadata.json
    2021-11-23T23:33:00.033+0530    reading metadata for MERN-STORE-80201.products from dump\MERN-STORE-80201\products.metadata.json
    2021-11-23T23:33:00.033+0530    reading metadata for MERN-STORE-80201.wishlists from dump\MERN-STORE-80201\wishlists.metadata.json
    2021-11-23T23:33:00.033+0530    reading metadata for MERN-STORE-80201.words from dump\MERN-STORE-80201\words.metadata.json
    2021-11-23T23:33:00.033+0530    restoring MERN-STORE-80201.products from dump\MERN-STORE-80201\products.bson
    2021-11-23T23:33:00.188+0530    restoring MERN-STORE-80201.carts from dump\MERN-STORE-80201\carts.bson
    2021-11-23T23:33:00.252+0530    restoring MERN-STORE-80201.wishlists from dump\MERN-STORE-80201\wishlists.bson
    2021-11-23T23:33:00.274+0530    restoring indexes for collection MERN-STORE-80201.products from metadata
    2021-11-23T23:33:00.335+0530    no indexes to restore
    2021-11-23T23:33:00.335+0530    finished restoring MERN-STORE-80201.carts (12 documents)
    2021-11-23T23:33:00.335+0530    reading metadata for MERN-STORE-80201.reviews from dump\MERN-STORE-80201\reviews.metadata.json
    2021-11-23T23:33:00.386+0530    restoring MERN-STORE-80201.words from dump\MERN-STORE-80201\words.bson
    2021-11-23T23:33:00.398+0530    no indexes to restore
    2021-11-23T23:33:00.398+0530    finished restoring MERN-STORE-80201.wishlists (15 documents)
    2021-11-23T23:33:00.398+0530    reading metadata for MERN-STORE-80201.users from dump\MERN-STORE-80201\users.metadata.json
    2021-11-23T23:33:00.398+0530    restoring MERN-STORE-80201.users from dump\MERN-STORE-80201\users.bson
    2021-11-23T23:33:00.422+0530    finished restoring MERN-STORE-80201.products (16 documents)
    2021-11-23T23:33:00.423+0530    reading metadata for MERN-STORE-80201.orders from dump\MERN-STORE-80201\orders.metadata.json
    2021-11-23T23:33:00.488+0530    restoring MERN-STORE-80201.reviews from dump\MERN-STORE-80201\reviews.bson
    2021-11-23T23:33:00.536+0530    restoring indexes for collection MERN-STORE-80201.users from metadata
    2021-11-23T23:33:00.570+0530    restoring MERN-STORE-80201.orders from dump\MERN-STORE-80201\orders.bson
    2021-11-23T23:33:00.586+0530    no indexes to restore
    2021-11-23T23:33:00.586+0530    finished restoring MERN-STORE-80201.words (23 documents)
    2021-11-23T23:33:00.586+0530    reading metadata for MERN-STORE-80201.categories from dump\MERN-STORE-80201\categories.metadata.json
    2021-11-23T23:33:00.587+0530    restoring MERN-STORE-80201.categories from dump\MERN-STORE-80201\categories.bson
    2021-11-23T23:33:00.633+0530    no indexes to restore
    2021-11-23T23:33:00.633+0530    finished restoring MERN-STORE-80201.reviews (7 documents)
    2021-11-23T23:33:00.633+0530    reading metadata for MERN-STORE-80201.addresses from dump\MERN-STORE-80201\addresses.metadata.json
    2021-11-23T23:33:00.719+0530    no indexes to restore
    2021-11-23T23:33:00.719+0530    finished restoring MERN-STORE-80201.orders (11 documents)
    2021-