{"id":4198,"date":"2020-09-16T15:23:10","date_gmt":"2020-09-16T07:23:10","guid":{"rendered":"https:\/\/www.webteach.tw\/?p=4198"},"modified":"2020-09-16T15:23:10","modified_gmt":"2020-09-16T07:23:10","slug":"mongodump-mongorestore","status":"publish","type":"post","link":"https:\/\/www.webteach.tw\/?p=4198","title":{"rendered":"[ Mongodb ] &#8211; How to backup and restore databases in Mongodb using mongodump and mongorestore \u5982\u4f55\u5728 Mongodb \u4e2d\u5982\u4f55\u5099\u4efd\u8207\u9084\u539f\u8cc7\u6599\u5eab\u4f7f\u7528 mongodump \u8207 mongorestore"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u4eca\u5929\u4f86\u4ecb\u7d39\u5728 Mongodb \u4e2d\u5982\u4f55\u5099\u4efd\u8207\u9084\u539f\u8cc7\u6599\u5eab\uff0c\u6211\u5011\u5c07\u4f7f\u7528 mongodump \u8207 mongorestore \u4f86\u9054\u5230\u6b64\u9700\u6c42\u3002<br \/><br \/>Today we will introduce how to backup and restore databases in Mongodb. We will use mongodump and mongorestore to meet this requirement.<\/p>\n\n\n<p class=\"wp-block-paragraph\">\u5099\u4efd\u6307\u4ee4\uff1a<\/p>\n\n\n<pre class=\"wp-block-code\"><code>mongodump -h localhost:27017 -u username -p password --collection collection_name --db database_name -o \/home\/jeff\/<\/code><\/pre>\n\n\n<p class=\"wp-block-paragraph\">-h mongodb-ip:mongodb-port \/\/\u8cc7\u6599\u5eabip:\u6240\u4f7f\u7528\u7684port<br \/>-u user \/\/\u4f7f\u7528\u8005<br \/>-p password \/\/\u5bc6\u78bc<br \/>&#8211;collection collection-name \/\/\u96c6\u5408\uff08\u8cc7\u6599\u8868\uff09\u540d\u7a31<br \/>&#8211;db database-name \/\/\u8cc7\u6599\u5eab\u540d\u7a31<br \/>-o output where \/home\/jeff\/ \/\/\u5b58\u5132\u5099\u4efd\u7684\u8cc7\u6599\u593e \u9019\u908a\u6703\u81ea\u52d5\u7522\u751f \u8cc7\u6599\u5eab\u540d\u7a31\u8cc7\u6599\u593e<\/p>\n\n\n<p class=\"wp-block-paragraph\">\u9084\u539f\u6307\u4ee4\uff1a<\/p>\n\n\n<pre class=\"wp-block-code\"><code>mongorestore -h localhost:27017 -u username -p password -d database_name .\/log\/log20200911.bson<\/code><\/pre>\n\n\n<p class=\"wp-block-paragraph\">-h mongodb-ip:mongodb-port \/\/\u8cc7\u6599\u5eabip:\u6240\u4f7f\u7528\u7684port<br \/>-u user \/\/\u4f7f\u7528\u8005<br \/>-p password \/\/\u5bc6\u78bc<br \/>-d database-name \/\/\u8cc7\u6599\u5eab\u540d\u7a31 \u5f8c\u9762\u7a7a\u4e00\u683c \u8f38\u5165\u8981\u9084\u539f\u7684.bson \u9019\u908a\u6bd4\u8f03\u7279\u5225\u662f\u9700\u8981\u8f38\u5165\u76f8\u5c0d\u8def\u5f91\uff08\u5be6\u6e2c\u6c7a\u5c0d\u8def\u5f91\u7121\u6cd5\u6210\u529f\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u5929\u4f86\u4ecb\u7d39\u5728 Mongodb \u4e2d\u5982\u4f55\u5099\u4efd\u8207\u9084\u539f\u8cc7\u6599\u5eab\uff0c\u6211\u5011\u5c07\u4f7f\u7528 mongodump \u8207 mongorestore \u4f86\u9054\u5230\u6b64\u9700\u6c42\u3002<br \/>\nToday we will introduce how to backup and restore databases in Mongodb. We will use mongodump and mongorestore to meet this requirement.<\/p>\n","protected":false},"author":1,"featured_media":3825,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[395,396,397,678],"class_list":["post-4198","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mongodb","tag-mongodb","tag-mongodump","tag-mongorestore","tag-678","hvn-theme-has-thumbnail"],"_links":{"self":[{"href":"https:\/\/www.webteach.tw\/index.php?rest_route=\/wp\/v2\/posts\/4198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webteach.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webteach.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webteach.tw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webteach.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4198"}],"version-history":[{"count":0,"href":"https:\/\/www.webteach.tw\/index.php?rest_route=\/wp\/v2\/posts\/4198\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webteach.tw\/index.php?rest_route=\/wp\/v2\/media\/3825"}],"wp:attachment":[{"href":"https:\/\/www.webteach.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webteach.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webteach.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}