{"id":26224,"date":"2023-06-25T21:55:40","date_gmt":"2023-06-25T19:55:40","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/?p=26224"},"modified":"2023-06-25T21:56:10","modified_gmt":"2023-06-25T19:56:10","slug":"mongodbbackup-and-restore-with-mongodump-and-mongorestore","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\/","title":{"rendered":"MongoDB:Backup and restore with mongodump and mongorestore"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction:<\/h2>\n\n\n\n<p>As for Redis , MongoDB has its own backup utility to export and import data.This tool allow you in a single command to backup your database and your collections and then to load them.<\/p>\n\n\n\n<p>To save your data, we will see how to use mongodump and then for restoration we will use mongorestore.Note that we can also use mongoimport and mongoexport but we will see the difference on this post.<\/p>\n\n\n\n<p>For this topic we will check how to use the commands and their role,there a may we to use it and many arguments to add in the command ( in this blog I will not use the authentication argument but of course it is a best practice to use it , the aim is to show you how to use the backup utility)<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">MongoDB backup utility<\/h2>\n\n\n\n<p>First of all ,to be able to use the backup utility you must have downloaded the MongoDB tools.<\/p>\n\n\n\n<p><strong><span style=\"text-decoration: underline\">Important:<\/span><\/strong><\/p>\n\n\n\n<p>Run all the backup commands from the system command line, not the <a href=\"https:\/\/www.mongodb.com\/docs\/manual\/reference\/mongo\/#mongodb-binary-bin.mongo\"><code>mongo<\/code><\/a> shell.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is mongodump<\/h2>\n\n\n\n<p><a href=\"https:\/\/www.mongodb.com\/docs\/database-tools\/mongodump\/#mongodb-binary-bin.mongodump\"><code>mongodump<\/code><\/a> is a utility that creates a binary export of a database&#8217;s contents.<\/p>\n\n\n\n<p><a href=\"https:\/\/www.mongodb.com\/docs\/database-tools\/mongodump\/#mongodb-binary-bin.mongodump\"><code>mongodump<\/code><\/a> can export data from:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Standalone deployments<\/li>\n\n\n\n<li>Replica sets<\/li>\n\n\n\n<li>Sharded clusters<\/li>\n<\/ul>\n\n\n\n<p><a href=\"https:\/\/www.mongodb.com\/docs\/database-tools\/mongodump\/#mongodb-binary-bin.mongodump\"><code>mongodump<\/code><\/a> can connect to <a href=\"https:\/\/www.mongodb.com\/docs\/manual\/reference\/program\/mongod\/#mongodb-binary-bin.mongod\"><code>mongod<\/code><\/a> and <a href=\"https:\/\/www.mongodb.com\/docs\/manual\/reference\/program\/mongos\/#mongodb-binary-bin.mongos\"><code>mongos<\/code><\/a> instances.<\/p>\n\n\n\n<p>The format of the dump file is in BSON ( binary file ) it has the advantage to take less space than a JSON export<\/p>\n\n\n\n<p>BSON file are not human readable whereas JSON file is.<\/p>\n\n\n\n<p>I advise you to use mongodump over mongimport if you need performance and the data in JSON format are suitable to transferred between heterogeneous systems,<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is mongorestore<\/h2>\n\n\n\n<p>The <a href=\"https:\/\/www.mongodb.com\/docs\/database-tools\/mongorestore\/#mongodb-binary-bin.mongorestore\"><code>mongorestore<\/code><\/a> program loads data from either a binary database dump created by <a href=\"https:\/\/www.mongodb.com\/docs\/database-tools\/mongodump\/#mongodb-binary-bin.mongodump\"><code>mongodump<\/code><\/a> or the standard input into a <a href=\"https:\/\/www.mongodb.com\/docs\/manual\/reference\/program\/mongod\/#mongodb-binary-bin.mongod\"><code>mongod<\/code><\/a> or <a href=\"https:\/\/www.mongodb.com\/docs\/manual\/reference\/program\/mongos\/#mongodb-binary-bin.mongos\"><code>mongos<\/code><\/a> instance.it will generate mainly a <strong>BSON <\/strong>file to be restored and a metadata file in JSON format<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is mongoimport <\/h2>\n\n\n\n<p>The&nbsp;<a href=\"https:\/\/docs.mongodb.com\/manual\/reference\/program\/mongoimport\/#bin.mongoimport\"><code>mongoimport<\/code><\/a>&nbsp;tool imports content from an extended JSON, CSV, or TSV export created by&nbsp;<a href=\"https:\/\/docs.mongodb.com\/manual\/reference\/program\/mongoexport\/#bin.mongoexport\"><code>mongoexport<\/code><\/a>, or potentially, another third-party export tool.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is mongoexport<\/h2>\n\n\n\n<p><a href=\"https:\/\/www.mongodb.com\/docs\/database-tools\/mongoexport\/#mongodb-binary-bin.mongoexport\"><code>mongoexport<\/code><\/a> is a command-line tool that produces a <strong>JSON <\/strong>or <strong>CSV <\/strong>export of data stored in a MongoDB instance.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The mongodump command<\/h2>\n\n\n\n<p><span style=\"text-decoration: underline\"><strong>Syntax<\/strong><\/span>:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\nmongodump --uri=&quot;mongodb:\/\/mongodb0.example.com:27017&quot; &#x5B;additional options]\nmongodump --user=your_username --db=your_db_name --password=your_password --authenticationDatabase=admin --out=the_path_where_your_DB_will_be_exported --collection=collection_name\n<\/pre><\/div>\n\n\n<p><strong><span style=\"text-decoration: underline\">Example<\/span><\/strong>:<\/p>\n\n\n\n<p>C:\\Program Files\\MongoDB\\Tools\\100\\bin&gt;mongodump  ( you can add many args )<\/p>\n\n\n\n<p>if you let the single <strong>mongodump <\/strong>command it will dump ALL the DB and store it in dump folder<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/MGDUMP_okk-1024x260.png\" alt=\"\" class=\"wp-image-26235\" width=\"947\" height=\"240\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/MGDUMP_okk-1024x260.png 1024w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/MGDUMP_okk-300x76.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/MGDUMP_okk-768x195.png 768w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/MGDUMP_okk.png 1423w\" sizes=\"auto, (max-width: 947px) 100vw, 947px\" \/><\/figure>\n\n\n\n<p>You can also dump a specific collection by using the specific argument <\/p>\n\n\n\n<p><code>C:\\Program Files\\MongoDB\\Tools\\100\\bin&gt;mongodump --db=admin --collection=system.users --out=data\/<\/code><br>2023-06-22T10:12:53.772+0200 writing admin.system.users to data\\admin\\system.users.bson<br>2023-06-22T10:12:53.814+0200 <strong>done dumping admin.system.users<\/strong> (2 documents)<\/p>\n\n\n\n<p>Another example to dump the collection <strong>TOP100PLAYERS <\/strong>from the DB <strong>ANOTHER_NEW_DATABASE <\/strong>and to store it in the <strong>data <\/strong>folder<\/p>\n\n\n\n<p><code>C:\\Program Files\\MongoDB\\Tools\\100\\bin&gt;mongodump --db=ANOTHER_NEW_DATABASE --collection=TOP100PLAYERS --out=data\/<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"997\" height=\"618\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-45.png\" alt=\"\" class=\"wp-image-26240\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-45.png 997w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-45-300x186.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-45-768x476.png 768w\" sizes=\"auto, (max-width: 997px) 100vw, 997px\" \/><\/figure>\n\n\n\n<p>You see in the folder the <strong>BSON <\/strong>file and the metadata.json file<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The mongrestore command<\/h2>\n\n\n\n<p><span style=\"text-decoration: underline\">Syntax:<\/span><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nmongorestore &amp;lt;options&amp;gt; &amp;lt;connection-string&amp;gt; &amp;lt;directory or file to restore&amp;gt;\n<\/pre><\/div>\n\n\n<p><code>mongorestore --db= &lt; new_db_name &gt; --collection= &lt; collection_name &gt; data\/ &lt; db_name &gt; \/ &lt; collection_name &gt; .bson<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"817\" height=\"41\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-46.png\" alt=\"\" class=\"wp-image-26242\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-46.png 817w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-46-300x15.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-46-768x39.png 768w\" sizes=\"auto, (max-width: 817px) 100vw, 817px\" \/><\/figure>\n\n\n\n<p><span style=\"text-decoration: underline\">Example:<\/span><\/p>\n\n\n\n<p><code>C:\\Program Files\\MongoDB\\Tools\\100\\bin\\data&gt;mongorestore --db=ANOTHER_NEW_DATABASE --collection=TOP100PLAYERS data\/ANOTHER_NEW_DATABASE\/TOP100PLAYERS.bson --drop<\/code><\/p>\n\n\n\n<p><span style=\"text-decoration: underline\">Note:<\/span><\/p>\n\n\n\n<p>The <strong>&#8211;drop<\/strong> arg which will avoid any issue if there is a database overwriting <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Data loss simulation<\/h2>\n\n\n\n<p>Make a backup before any change ( mongodump) , after that let&#8217;s remove an entry from a collection and see if we can restore it<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"461\" height=\"291\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-54.png\" alt=\"\" class=\"wp-image-26268\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-54.png 461w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-54-300x189.png 300w\" sizes=\"auto, (max-width: 461px) 100vw, 461px\" \/><\/figure>\n\n\n\n<p>As you see you have 3 Barcelona legends , unfortunately I am still not as the 2 others top players level so they decide to remove my name.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-48.png\" alt=\"\" class=\"wp-image-26254\" width=\"698\" height=\"332\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-48.png 591w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-48-300x143.png 300w\" sizes=\"auto, (max-width: 698px) 100vw, 698px\" \/><\/figure>\n\n\n\n<p><strong><span style=\"text-decoration: underline\">Reminder<\/span><\/strong><\/p>\n\n\n\n<p>To remove a entry from a collection :<\/p>\n\n\n\n<p>From the DB you want to remove the entry:<\/p>\n\n\n\n<p><code>db.collection_name.deleteOne ( filter, elements of the collection ) <\/code><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndb.collection.deleteOne(   &amp;lt;filter&amp;gt;,   {      writeConcern: &amp;lt;document&amp;gt;,      collation: &amp;lt;document&amp;gt;,      hint: &amp;lt;document|string&amp;gt;        \/\/ Available starting in MongoDB 4.4   })\n<\/pre><\/div>\n\n\n<p>Example:<\/p>\n\n\n\n<p><code>db.TOP100PLAYERS.deleteOne( { \"Name\":\"Nabil\" } )<\/code><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Note:<\/p>\n\n\n\n<p>The command to add entry is <\/p>\n\n\n\n<p><code>db.getCollection('collection_name').insertOne({\"key1\":\"value\",\"key2\":\"value\"});<\/code><\/p>\n\n\n\n<p><code>db.getCollection('TOP100PLAYERS').insertOne({\"Name\":\"Nabil\",\"Club\":\"FC Barcelona\"});<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Restore the data<\/h2>\n\n\n\n<p>Now,after watching some of my youtube football skills they decide to give me back my place in this trio , so let&#8217;s restore  the collection!<\/p>\n\n\n\n<p><code>C:\\Program Files\\MongoDB\\Tools\\100\\bin&gt;mongorestore --db=ANOTHER_NEW_DATABASE --collection=TOP100PLAYERS data\/ANOTHER_NEW_DATABASE\/TOP100PLAYERS.bson --drop<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/Capture-1024x176.png\" alt=\"\" class=\"wp-image-26264\" width=\"1097\" height=\"188\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/Capture-1024x176.png 1024w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/Capture-300x52.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/Capture-768x132.png 768w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/Capture-1536x264.png 1536w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/Capture.png 1889w\" sizes=\"auto, (max-width: 1097px) 100vw, 1097px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Let&#8217;s see now if the name is restored in the collection <\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"569\" height=\"577\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-53.png\" alt=\"\" class=\"wp-image-26266\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-53.png 569w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-53-296x300.png 296w\" sizes=\"auto, (max-width: 569px) 100vw, 569px\" \/><\/figure>\n\n\n\n<p>So as we see the entry is now restored and have the same object ID as expected \ud83d\ude42<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to add or move a collection to another database<\/h2>\n\n\n\n<p>As a bonus ,There is a useful command which allow you to copy or move a collection to another database<\/p>\n\n\n\n<p><code>db.runCommand({renameCollection:\"db_name.collection_name\",to:\"other_db_name.collection_name\"})<\/code><\/p>\n\n\n\n<p><span style=\"text-decoration: underline\"><strong>warning<\/strong>:<\/span><\/p>\n\n\n\n<p>You have to send this command from the admin database otherwise it will through an error as on the screenshot below<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"361\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-57-1024x361.png\" alt=\"\" class=\"wp-image-26274\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-57-1024x361.png 1024w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-57-300x106.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-57-768x271.png 768w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-57.png 1061w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><span style=\"text-decoration: underline\"><strong>Example<\/strong><\/span><\/p>\n\n\n\n<p><code>db.runCommand({renameCollection:\"NEW_DB.TOP100PLAYERS\"<\/code>,to:&#8221;ANOTHER_NEW_DATABASE.TOP100PLAYERS_MOVED_TO_ANOTHERDB&#8221;})<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"361\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-56-1024x361.png\" alt=\"\" class=\"wp-image-26273\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-56-1024x361.png 1024w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-56-300x106.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-56-768x271.png 768w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-56.png 1061w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Use the admin database to perform it:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"487\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-58-1024x487.png\" alt=\"\" class=\"wp-image-26275\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-58-1024x487.png 1024w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-58-300x143.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-58-768x365.png 768w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/image-58.png 1026w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>That&#8217;s it, you moved your collection and can also rename it if you want.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion <\/h2>\n\n\n\n<p>You know now how to use the MongoDB tools <strong>mongodump <\/strong>and <strong>mongorestore <\/strong>, to perform easily your backup with any lack of performance.We also see few commands that allow you to move your collections on other databases which can be also really useful.<\/p>\n\n\n\n<p>Feel free to check the <a href=\"https:\/\/www.dbi-services.com\/blog\/author\/nabilsaoual\/\">my other blogs<\/a> and also the <a href=\"https:\/\/www.dbi-services.com\/blog\/\">dbi bloggers<\/a> and share with us if the post was helpful \ud83d\ude00 <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction: As for Redis , MongoDB has its own backup utility to export and import data.This tool allow you in a single command to backup your database and your collections and then to load them. To save your data, we will see how to use mongodump and then for restoration we will use mongorestore.Note that [&hellip;]<\/p>\n","protected":false},"author":40,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1739],"tags":[],"type_dbi":[],"class_list":["post-26224","post","type-post","status-publish","format-standard","hentry","category-nosql"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.5) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>MongoDB:Backup and restore with mongodump and mongorestore - dbi Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbi-services.com\/blog\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MongoDB:Backup and restore with mongodump and mongorestore\" \/>\n<meta property=\"og:description\" content=\"Introduction: As for Redis , MongoDB has its own backup utility to export and import data.This tool allow you in a single command to backup your database and your collections and then to load them. To save your data, we will see how to use mongodump and then for restoration we will use mongorestore.Note that [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi Blog\" \/>\n<meta property=\"article:published_time\" content=\"2023-06-25T19:55:40+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-25T19:56:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/MGDUMP_okk-1024x260.png\" \/>\n<meta name=\"author\" content=\"Middleware Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Middleware Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\\\/\"},\"author\":{\"name\":\"Middleware Team\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/8d8563acfc6e604cce6507f45bac0ea1\"},\"headline\":\"MongoDB:Backup and restore with mongodump and mongorestore\",\"datePublished\":\"2023-06-25T19:55:40+00:00\",\"dateModified\":\"2023-06-25T19:56:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\\\/\"},\"wordCount\":765,\"commentCount\":1,\"image\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2023\\\/06\\\/MGDUMP_okk-1024x260.png\",\"articleSection\":[\"NoSQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\\\/\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\\\/\",\"name\":\"MongoDB:Backup and restore with mongodump and mongorestore - dbi Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2023\\\/06\\\/MGDUMP_okk-1024x260.png\",\"datePublished\":\"2023-06-25T19:55:40+00:00\",\"dateModified\":\"2023-06-25T19:56:10+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/8d8563acfc6e604cce6507f45bac0ea1\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2023\\\/06\\\/MGDUMP_okk-1024x260.png\",\"contentUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2023\\\/06\\\/MGDUMP_okk-1024x260.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MongoDB:Backup and restore with mongodump and mongorestore\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\",\"name\":\"dbi Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/8d8563acfc6e604cce6507f45bac0ea1\",\"name\":\"Middleware Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ddcae7ba0f9d1a0e7ae707f0e689e4a9c95bb48ec49c8e6d9cc86d43f4121cb6?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ddcae7ba0f9d1a0e7ae707f0e689e4a9c95bb48ec49c8e6d9cc86d43f4121cb6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ddcae7ba0f9d1a0e7ae707f0e689e4a9c95bb48ec49c8e6d9cc86d43f4121cb6?s=96&d=mm&r=g\",\"caption\":\"Middleware Team\"},\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/author\\\/middleware-team\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"MongoDB:Backup and restore with mongodump and mongorestore - dbi Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dbi-services.com\/blog\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\/","og_locale":"en_US","og_type":"article","og_title":"MongoDB:Backup and restore with mongodump and mongorestore","og_description":"Introduction: As for Redis , MongoDB has its own backup utility to export and import data.This tool allow you in a single command to backup your database and your collections and then to load them. To save your data, we will see how to use mongodump and then for restoration we will use mongorestore.Note that [&hellip;]","og_url":"https:\/\/www.dbi-services.com\/blog\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\/","og_site_name":"dbi Blog","article_published_time":"2023-06-25T19:55:40+00:00","article_modified_time":"2023-06-25T19:56:10+00:00","og_image":[{"url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/MGDUMP_okk-1024x260.png","type":"","width":"","height":""}],"author":"Middleware Team","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Middleware Team","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\/"},"author":{"name":"Middleware Team","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d8563acfc6e604cce6507f45bac0ea1"},"headline":"MongoDB:Backup and restore with mongodump and mongorestore","datePublished":"2023-06-25T19:55:40+00:00","dateModified":"2023-06-25T19:56:10+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\/"},"wordCount":765,"commentCount":1,"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\/#primaryimage"},"thumbnailUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/MGDUMP_okk-1024x260.png","articleSection":["NoSQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\/","url":"https:\/\/www.dbi-services.com\/blog\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\/","name":"MongoDB:Backup and restore with mongodump and mongorestore - dbi Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\/#primaryimage"},"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\/#primaryimage"},"thumbnailUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/MGDUMP_okk-1024x260.png","datePublished":"2023-06-25T19:55:40+00:00","dateModified":"2023-06-25T19:56:10+00:00","author":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d8563acfc6e604cce6507f45bac0ea1"},"breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbi-services.com\/blog\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\/#primaryimage","url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/MGDUMP_okk-1024x260.png","contentUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/06\/MGDUMP_okk-1024x260.png"},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/mongodbbackup-and-restore-with-mongodump-and-mongorestore\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"MongoDB:Backup and restore with mongodump and mongorestore"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d8563acfc6e604cce6507f45bac0ea1","name":"Middleware Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/ddcae7ba0f9d1a0e7ae707f0e689e4a9c95bb48ec49c8e6d9cc86d43f4121cb6?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/ddcae7ba0f9d1a0e7ae707f0e689e4a9c95bb48ec49c8e6d9cc86d43f4121cb6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ddcae7ba0f9d1a0e7ae707f0e689e4a9c95bb48ec49c8e6d9cc86d43f4121cb6?s=96&d=mm&r=g","caption":"Middleware Team"},"url":"https:\/\/www.dbi-services.com\/blog\/author\/middleware-team\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/26224","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/40"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=26224"}],"version-history":[{"count":38,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/26224\/revisions"}],"predecessor-version":[{"id":26289,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/26224\/revisions\/26289"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=26224"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=26224"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=26224"},{"taxonomy":"type","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/type_dbi?post=26224"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}