Unable to restore BSON data into cosmos collection using mongorestore [duplicate]












0
















This question already has an answer here:




  • Restore data Mongodb from JSON

    2 answers




I have exported data from Azure CosmosDB collection using below command,




mongoexport -h xyz.documents.azure.com:10255 -u DB -p password -d DB
-c Product --ssl --sslAllowInvalidCertificates -o backup.bson




Now im restoring it to same collection using below command,




mongorestore -h xyz.documents.azure.com:10255 -u user1 -p password -d
DB -c Product --ssl --sslAllowInvalidCertificates --dir backup.bson
--numParallelCollections=1




However getting below error,




Failed: xyz.Product: error restoring from backup.bson: reading bson
input: invalid BSONSize: 1767842427 bytes











share|improve this question













marked as duplicate by David Makogon, Neil Lunn mongodb
Users with the  mongodb badge can single-handedly close mongodb questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 24 '18 at 9:28


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • aah.. my bad. Can you tell me what is the MongoDB version are you using?

    – Aniket Maithani
    Nov 21 '18 at 14:56






  • 1





    Your issue is that you're exporting and importing with different tools. Either use mongoexport + mongoimport, or mongodump + mongorestore.

    – David Makogon
    Nov 21 '18 at 22:21











  • Thank for the clarification, @DavidMakogon. it worked for me.

    – Ganesh
    Nov 22 '18 at 12:42











  • @Ganesh - good to hear. I posted as a proper answer, so this can be closed out accordingly.

    – David Makogon
    Nov 22 '18 at 12:47
















0
















This question already has an answer here:




  • Restore data Mongodb from JSON

    2 answers




I have exported data from Azure CosmosDB collection using below command,




mongoexport -h xyz.documents.azure.com:10255 -u DB -p password -d DB
-c Product --ssl --sslAllowInvalidCertificates -o backup.bson




Now im restoring it to same collection using below command,




mongorestore -h xyz.documents.azure.com:10255 -u user1 -p password -d
DB -c Product --ssl --sslAllowInvalidCertificates --dir backup.bson
--numParallelCollections=1




However getting below error,




Failed: xyz.Product: error restoring from backup.bson: reading bson
input: invalid BSONSize: 1767842427 bytes











share|improve this question













marked as duplicate by David Makogon, Neil Lunn mongodb
Users with the  mongodb badge can single-handedly close mongodb questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 24 '18 at 9:28


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • aah.. my bad. Can you tell me what is the MongoDB version are you using?

    – Aniket Maithani
    Nov 21 '18 at 14:56






  • 1





    Your issue is that you're exporting and importing with different tools. Either use mongoexport + mongoimport, or mongodump + mongorestore.

    – David Makogon
    Nov 21 '18 at 22:21











  • Thank for the clarification, @DavidMakogon. it worked for me.

    – Ganesh
    Nov 22 '18 at 12:42











  • @Ganesh - good to hear. I posted as a proper answer, so this can be closed out accordingly.

    – David Makogon
    Nov 22 '18 at 12:47














0












0








0









This question already has an answer here:




  • Restore data Mongodb from JSON

    2 answers




I have exported data from Azure CosmosDB collection using below command,




mongoexport -h xyz.documents.azure.com:10255 -u DB -p password -d DB
-c Product --ssl --sslAllowInvalidCertificates -o backup.bson




Now im restoring it to same collection using below command,




mongorestore -h xyz.documents.azure.com:10255 -u user1 -p password -d
DB -c Product --ssl --sslAllowInvalidCertificates --dir backup.bson
--numParallelCollections=1




However getting below error,




Failed: xyz.Product: error restoring from backup.bson: reading bson
input: invalid BSONSize: 1767842427 bytes











share|improve this question















This question already has an answer here:




  • Restore data Mongodb from JSON

    2 answers




I have exported data from Azure CosmosDB collection using below command,




mongoexport -h xyz.documents.azure.com:10255 -u DB -p password -d DB
-c Product --ssl --sslAllowInvalidCertificates -o backup.bson




Now im restoring it to same collection using below command,




mongorestore -h xyz.documents.azure.com:10255 -u user1 -p password -d
DB -c Product --ssl --sslAllowInvalidCertificates --dir backup.bson
--numParallelCollections=1




However getting below error,




Failed: xyz.Product: error restoring from backup.bson: reading bson
input: invalid BSONSize: 1767842427 bytes






This question already has an answer here:




  • Restore data Mongodb from JSON

    2 answers








mongodb mongodb-query azure-cosmosdb






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 21 '18 at 14:07









GaneshGanesh

367




367




marked as duplicate by David Makogon, Neil Lunn mongodb
Users with the  mongodb badge can single-handedly close mongodb questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 24 '18 at 9:28


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by David Makogon, Neil Lunn mongodb
Users with the  mongodb badge can single-handedly close mongodb questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 24 '18 at 9:28


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • aah.. my bad. Can you tell me what is the MongoDB version are you using?

    – Aniket Maithani
    Nov 21 '18 at 14:56






  • 1





    Your issue is that you're exporting and importing with different tools. Either use mongoexport + mongoimport, or mongodump + mongorestore.

    – David Makogon
    Nov 21 '18 at 22:21











  • Thank for the clarification, @DavidMakogon. it worked for me.

    – Ganesh
    Nov 22 '18 at 12:42











  • @Ganesh - good to hear. I posted as a proper answer, so this can be closed out accordingly.

    – David Makogon
    Nov 22 '18 at 12:47



















  • aah.. my bad. Can you tell me what is the MongoDB version are you using?

    – Aniket Maithani
    Nov 21 '18 at 14:56






  • 1





    Your issue is that you're exporting and importing with different tools. Either use mongoexport + mongoimport, or mongodump + mongorestore.

    – David Makogon
    Nov 21 '18 at 22:21











  • Thank for the clarification, @DavidMakogon. it worked for me.

    – Ganesh
    Nov 22 '18 at 12:42











  • @Ganesh - good to hear. I posted as a proper answer, so this can be closed out accordingly.

    – David Makogon
    Nov 22 '18 at 12:47

















aah.. my bad. Can you tell me what is the MongoDB version are you using?

– Aniket Maithani
Nov 21 '18 at 14:56





aah.. my bad. Can you tell me what is the MongoDB version are you using?

– Aniket Maithani
Nov 21 '18 at 14:56




1




1





Your issue is that you're exporting and importing with different tools. Either use mongoexport + mongoimport, or mongodump + mongorestore.

– David Makogon
Nov 21 '18 at 22:21





Your issue is that you're exporting and importing with different tools. Either use mongoexport + mongoimport, or mongodump + mongorestore.

– David Makogon
Nov 21 '18 at 22:21













Thank for the clarification, @DavidMakogon. it worked for me.

– Ganesh
Nov 22 '18 at 12:42





Thank for the clarification, @DavidMakogon. it worked for me.

– Ganesh
Nov 22 '18 at 12:42













@Ganesh - good to hear. I posted as a proper answer, so this can be closed out accordingly.

– David Makogon
Nov 22 '18 at 12:47





@Ganesh - good to hear. I posted as a proper answer, so this can be closed out accordingly.

– David Makogon
Nov 22 '18 at 12:47












2 Answers
2






active

oldest

votes


















1














Just to close this question properly: The issue is that you're exporting and importing with different tools.



Either use:





  • mongoexport + mongoimport (which writes and reads JSON or CSV)


  • mongodump + mongorestore (which writes & reads a binary file).


You can't mix the two, and that was the root cause of your error, exporting as text and trying to import as BSON.






share|improve this answer































    -1














    Looks like possible duplicate of mongorestore fails due to invalid BSONSize . Can you check the link and try once again?






    share|improve this answer
























    • He is using mongodump to export data while im using mongoexport.

      – Ganesh
      Nov 21 '18 at 14:39






    • 1





      I am not a pro in this but as per my understanding Mongodump uses bson file structure and in general it also maintain the data types. In case you're using mongoexport you will lose data type of the values. That's why mongodump is more preferred if you need to import back your DB. A quick google search gave me the following link : dba.stackexchange.com/questions/194370/… HTH

      – Aniket Maithani
      Nov 21 '18 at 15:05






    • 1





      This has nothing to do with size; the export and import tools are different. mongorestore only works with data from mongodump, not mongoexport, per my comment under the question. This is just a mixup of which tools are being used.

      – David Makogon
      Nov 21 '18 at 22:23




















    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Just to close this question properly: The issue is that you're exporting and importing with different tools.



    Either use:





    • mongoexport + mongoimport (which writes and reads JSON or CSV)


    • mongodump + mongorestore (which writes & reads a binary file).


    You can't mix the two, and that was the root cause of your error, exporting as text and trying to import as BSON.






    share|improve this answer




























      1














      Just to close this question properly: The issue is that you're exporting and importing with different tools.



      Either use:





      • mongoexport + mongoimport (which writes and reads JSON or CSV)


      • mongodump + mongorestore (which writes & reads a binary file).


      You can't mix the two, and that was the root cause of your error, exporting as text and trying to import as BSON.






      share|improve this answer


























        1












        1








        1







        Just to close this question properly: The issue is that you're exporting and importing with different tools.



        Either use:





        • mongoexport + mongoimport (which writes and reads JSON or CSV)


        • mongodump + mongorestore (which writes & reads a binary file).


        You can't mix the two, and that was the root cause of your error, exporting as text and trying to import as BSON.






        share|improve this answer













        Just to close this question properly: The issue is that you're exporting and importing with different tools.



        Either use:





        • mongoexport + mongoimport (which writes and reads JSON or CSV)


        • mongodump + mongorestore (which writes & reads a binary file).


        You can't mix the two, and that was the root cause of your error, exporting as text and trying to import as BSON.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 '18 at 12:46









        David MakogonDavid Makogon

        57.2k15108155




        57.2k15108155

























            -1














            Looks like possible duplicate of mongorestore fails due to invalid BSONSize . Can you check the link and try once again?






            share|improve this answer
























            • He is using mongodump to export data while im using mongoexport.

              – Ganesh
              Nov 21 '18 at 14:39






            • 1





              I am not a pro in this but as per my understanding Mongodump uses bson file structure and in general it also maintain the data types. In case you're using mongoexport you will lose data type of the values. That's why mongodump is more preferred if you need to import back your DB. A quick google search gave me the following link : dba.stackexchange.com/questions/194370/… HTH

              – Aniket Maithani
              Nov 21 '18 at 15:05






            • 1





              This has nothing to do with size; the export and import tools are different. mongorestore only works with data from mongodump, not mongoexport, per my comment under the question. This is just a mixup of which tools are being used.

              – David Makogon
              Nov 21 '18 at 22:23


















            -1














            Looks like possible duplicate of mongorestore fails due to invalid BSONSize . Can you check the link and try once again?






            share|improve this answer
























            • He is using mongodump to export data while im using mongoexport.

              – Ganesh
              Nov 21 '18 at 14:39






            • 1





              I am not a pro in this but as per my understanding Mongodump uses bson file structure and in general it also maintain the data types. In case you're using mongoexport you will lose data type of the values. That's why mongodump is more preferred if you need to import back your DB. A quick google search gave me the following link : dba.stackexchange.com/questions/194370/… HTH

              – Aniket Maithani
              Nov 21 '18 at 15:05






            • 1





              This has nothing to do with size; the export and import tools are different. mongorestore only works with data from mongodump, not mongoexport, per my comment under the question. This is just a mixup of which tools are being used.

              – David Makogon
              Nov 21 '18 at 22:23
















            -1












            -1








            -1







            Looks like possible duplicate of mongorestore fails due to invalid BSONSize . Can you check the link and try once again?






            share|improve this answer













            Looks like possible duplicate of mongorestore fails due to invalid BSONSize . Can you check the link and try once again?







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 21 '18 at 14:10









            Aniket MaithaniAniket Maithani

            12010




            12010













            • He is using mongodump to export data while im using mongoexport.

              – Ganesh
              Nov 21 '18 at 14:39






            • 1





              I am not a pro in this but as per my understanding Mongodump uses bson file structure and in general it also maintain the data types. In case you're using mongoexport you will lose data type of the values. That's why mongodump is more preferred if you need to import back your DB. A quick google search gave me the following link : dba.stackexchange.com/questions/194370/… HTH

              – Aniket Maithani
              Nov 21 '18 at 15:05






            • 1





              This has nothing to do with size; the export and import tools are different. mongorestore only works with data from mongodump, not mongoexport, per my comment under the question. This is just a mixup of which tools are being used.

              – David Makogon
              Nov 21 '18 at 22:23





















            • He is using mongodump to export data while im using mongoexport.

              – Ganesh
              Nov 21 '18 at 14:39






            • 1





              I am not a pro in this but as per my understanding Mongodump uses bson file structure and in general it also maintain the data types. In case you're using mongoexport you will lose data type of the values. That's why mongodump is more preferred if you need to import back your DB. A quick google search gave me the following link : dba.stackexchange.com/questions/194370/… HTH

              – Aniket Maithani
              Nov 21 '18 at 15:05






            • 1





              This has nothing to do with size; the export and import tools are different. mongorestore only works with data from mongodump, not mongoexport, per my comment under the question. This is just a mixup of which tools are being used.

              – David Makogon
              Nov 21 '18 at 22:23



















            He is using mongodump to export data while im using mongoexport.

            – Ganesh
            Nov 21 '18 at 14:39





            He is using mongodump to export data while im using mongoexport.

            – Ganesh
            Nov 21 '18 at 14:39




            1




            1





            I am not a pro in this but as per my understanding Mongodump uses bson file structure and in general it also maintain the data types. In case you're using mongoexport you will lose data type of the values. That's why mongodump is more preferred if you need to import back your DB. A quick google search gave me the following link : dba.stackexchange.com/questions/194370/… HTH

            – Aniket Maithani
            Nov 21 '18 at 15:05





            I am not a pro in this but as per my understanding Mongodump uses bson file structure and in general it also maintain the data types. In case you're using mongoexport you will lose data type of the values. That's why mongodump is more preferred if you need to import back your DB. A quick google search gave me the following link : dba.stackexchange.com/questions/194370/… HTH

            – Aniket Maithani
            Nov 21 '18 at 15:05




            1




            1





            This has nothing to do with size; the export and import tools are different. mongorestore only works with data from mongodump, not mongoexport, per my comment under the question. This is just a mixup of which tools are being used.

            – David Makogon
            Nov 21 '18 at 22:23







            This has nothing to do with size; the export and import tools are different. mongorestore only works with data from mongodump, not mongoexport, per my comment under the question. This is just a mixup of which tools are being used.

            – David Makogon
            Nov 21 '18 at 22:23





            這個網誌中的熱門文章

            Academy of Television Arts & Sciences

            L'Équipe

            1995 France bombings