{"id":174437,"date":"2024-11-07T21:51:26","date_gmt":"2024-11-07T13:51:26","guid":{"rendered":"https:\/\/server.hk\/cnblog\/174437\/"},"modified":"2024-11-07T21:51:27","modified_gmt":"2024-11-07T13:51:27","slug":"%e5%a6%82%e4%bd%95%e9%80%b2%e8%a1%8c%e5%bf%ab%e9%80%9f%e7%9a%84%e9%9b%b2%e6%95%b8%e6%93%9a%e5%ba%ab%e6%81%a2%e5%be%a9%ef%bc%9f-%e5%bf%ab%e9%9b%b2%e6%95%b8%e6%93%9a%e5%ba%ab%e6%81%a2%e5%be%a9","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/174437\/","title":{"rendered":"\u5982\u4f55\u9032\u884c\u5feb\u901f\u7684\u96f2\u6578\u64da\u5eab\u6062\u5fa9\uff1f (\u5feb\u96f2\u6578\u64da\u5eab\u6062\u5fa9)"},"content":{"rendered":"<h1 id=\"%e5%a6%82%e4%bd%95%e9%80%b2%e8%a1%8c%e5%bf%ab%e9%80%9f%e7%9a%84%e9%9b%b2%e6%95%b8%e6%93%9a%e5%ba%ab%e6%81%a2%e5%be%a9%ef%bc%9f-%e5%bf%ab%e9%9b%b2%e6%95%b8%e6%93%9a%e5%ba%ab%e6%81%a2%e5%be%a9-FuMotXxseb\">\u5982\u4f55\u9032\u884c\u5feb\u901f\u7684\u96f2\u6578\u64da\u5eab\u6062\u5fa9\uff1f (\u5feb\u96f2\u6578\u64da\u5eab\u6062\u5fa9)<\/h1>\n<p>\u5728\u7576\u4eca\u6578\u64da\u9a45\u52d5\u7684\u4e16\u754c\u4e2d\uff0c\u6578\u64da\u5eab\u7684\u53ef\u9760\u6027\u548c\u53ef\u7528\u6027\u81f3\u95dc\u91cd\u8981\u3002\u96f2\u6578\u64da\u5eab\u4f5c\u70ba\u4e00\u7a2e\u9748\u6d3b\u4e14\u53ef\u64f4\u5c55\u7684\u89e3\u6c7a\u65b9\u6848\uff0c\u8d8a\u4f86\u8d8a\u53d7\u5230\u4f01\u696d\u7684\u9752\u775e\u3002\u7136\u800c\uff0c\u6578\u64da\u4e1f\u5931\u6216\u640d\u58de\u7684\u98a8\u96aa\u59cb\u7d42\u5b58\u5728\uff0c\u56e0\u6b64\u5feb\u901f\u6062\u5fa9\u6578\u64da\u5eab\u7684\u80fd\u529b\u8b8a\u5f97\u5c24\u70ba\u91cd\u8981\u3002\u672c\u6587\u5c07\u63a2\u8a0e\u5982\u4f55\u9032\u884c\u5feb\u901f\u7684\u96f2\u6578\u64da\u5eab\u6062\u5fa9\uff0c\u4e26\u63d0\u4f9b\u4e00\u4e9b\u5be6\u7528\u7684\u5efa\u8b70\u548c\u6280\u8853\u3002<\/p>\n<h2 id=\"%e9%9b%b2%e6%95%b8%e6%93%9a%e5%ba%ab%e6%81%a2%e5%be%a9%e7%9a%84%e5%9f%ba%e6%9c%ac%e6%a6%82%e5%bf%b5-FuMotXxseb\">\u96f2\u6578\u64da\u5eab\u6062\u5fa9\u7684\u57fa\u672c\u6982\u5ff5<\/h2>\n<p>\u96f2\u6578\u64da\u5eab\u6062\u5fa9\u662f\u6307\u5728\u6578\u64da\u4e1f\u5931\u6216\u640d\u58de\u7684\u60c5\u6cc1\u4e0b\uff0c\u901a\u904e\u5404\u7a2e\u6280\u8853\u624b\u6bb5\u5c07\u6578\u64da\u5eab\u6062\u5fa9\u5230\u6b63\u5e38\u904b\u884c\u72c0\u614b\u7684\u904e\u7a0b\u3002\u9019\u4e00\u904e\u7a0b\u901a\u5e38\u5305\u62ec\u6578\u64da\u5099\u4efd\u3001\u6578\u64da\u6062\u5fa9\u548c\u7cfb\u7d71\u6aa2\u67e5\u7b49\u6b65\u9a5f\u3002\u96f2\u6578\u64da\u5eab\u7684\u7279\u9ede\u4f7f\u5f97\u9019\u4e00\u904e\u7a0b\u53ef\u4ee5\u66f4\u52a0\u9ad8\u6548\u548c\u9748\u6d3b\u3002<\/p>\n<h2 id=\"%e6%95%b8%e6%93%9a%e5%82%99%e4%bb%bd%e7%9a%84%e9%87%8d%e8%a6%81%e6%80%a7-FuMotXxseb\">\u6578\u64da\u5099\u4efd\u7684\u91cd\u8981\u6027<\/h2>\n<p>\u5728\u9032\u884c\u6578\u64da\u5eab\u6062\u5fa9\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u78ba\u4fdd\u6578\u64da\u7684\u5b9a\u671f\u5099\u4efd\u3002\u5099\u4efd\u662f\u9632\u6b62\u6578\u64da\u4e1f\u5931\u7684\u7b2c\u4e00\u9053\u9632\u7dda\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5099\u4efd\u7b56\u7565\uff1a<\/p>\n<ul>\n<li><strong>\u5168\u91cf\u5099\u4efd\uff1a<\/strong>\u5b9a\u671f\u5c0d\u6574\u500b\u6578\u64da\u5eab\u9032\u884c\u5099\u4efd\uff0c\u9069\u5408\u6578\u64da\u91cf\u8f03\u5c0f\u7684\u60c5\u6cc1\u3002<\/li>\n<li><strong>\u589e\u91cf\u5099\u4efd\uff1a<\/strong>\u50c5\u5099\u4efd\u81ea\u4e0a\u6b21\u5099\u4efd\u4ee5\u4f86\u767c\u751f\u8b8a\u66f4\u7684\u6578\u64da\uff0c\u7bc0\u7701\u5b58\u5132\u7a7a\u9593\u548c\u6642\u9593\u3002<\/li>\n<li><strong>\u5dee\u7570\u5099\u4efd\uff1a<\/strong>\u5099\u4efd\u81ea\u4e0a\u6b21\u5168\u91cf\u5099\u4efd\u4ee5\u4f86\u7684\u6240\u6709\u8b8a\u66f4\uff0c\u63d0\u4f9b\u66f4\u5feb\u7684\u6062\u5fa9\u901f\u5ea6\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%bf%ab%e9%80%9f%e6%81%a2%e5%be%a9%e7%9a%84%e6%8a%80%e8%a1%93%e6%89%8b%e6%ae%b5-FuMotXxseb\">\u5feb\u901f\u6062\u5fa9\u7684\u6280\u8853\u624b\u6bb5<\/h2>\n<p>\u5728\u6578\u64da\u4e1f\u5931\u7684\u60c5\u6cc1\u4e0b\uff0c\u5feb\u901f\u6062\u5fa9\u6578\u64da\u5eab\u7684\u6280\u8853\u624b\u6bb5\u4e3b\u8981\u5305\u62ec\u4ee5\u4e0b\u5e7e\u7a2e\uff1a<\/p>\n<h3 id=\"1-%e4%bd%bf%e7%94%a8%e5%bf%ab%e7%85%a7%e6%8a%80%e8%a1%93-FuMotXxseb\">1. \u4f7f\u7528\u5feb\u7167\u6280\u8853<\/h3>\n<p>\u8a31\u591a\u96f2\u670d\u52d9\u63d0\u4f9b\u5546\u652f\u6301\u5feb\u7167\u529f\u80fd\uff0c\u9019\u662f\u4e00\u7a2e\u5feb\u901f\u7684\u5099\u4efd\u548c\u6062\u5fa9\u65b9\u6cd5\u3002\u5feb\u7167\u53ef\u4ee5\u5728\u5e7e\u79d2\u9418\u5167\u6355\u6349\u6574\u500b\u6578\u64da\u5eab\u7684\u72c0\u614b\uff0c\u4e26\u5728\u9700\u8981\u6642\u8fc5\u901f\u6062\u5fa9\u3002<\/p>\n<pre><code>-- \u5275\u5efa\u5feb\u7167\nCREATE SNAPSHOT my_snapshot ON my_database;\n<\/code><\/pre>\n<h3 id=\"2-%e5%88%a9%e7%94%a8%e6%97%a5%e8%aa%8c%e6%81%a2%e5%be%a9-FuMotXxseb\">2. \u5229\u7528\u65e5\u8a8c\u6062\u5fa9<\/h3>\n<p>\u6578\u64da\u5eab\u7cfb\u7d71\u901a\u5e38\u6703\u8a18\u9304\u6240\u6709\u7684\u4e8b\u52d9\u65e5\u8a8c\uff0c\u9019\u4e9b\u65e5\u8a8c\u53ef\u4ee5\u7528\u4f86\u6062\u5fa9\u5230\u67d0\u4e00\u7279\u5b9a\u6642\u9593\u9ede\u3002\u9019\u7a2e\u65b9\u6cd5\u7279\u5225\u9069\u5408\u9700\u8981\u7cbe\u78ba\u6062\u5fa9\u7684\u60c5\u6cc1\u3002<\/p>\n<pre><code>-- \u6062\u5fa9\u5230\u7279\u5b9a\u6642\u9593\nRESTORE DATABASE my_database FROM LOG my_log WITH STOPAT = '2023-10-01 10:00:00';\n<\/code><\/pre>\n<h3 id=\"3-%e8%87%aa%e5%8b%95%e5%8c%96%e6%81%a2%e5%be%a9%e6%b5%81%e7%a8%8b-FuMotXxseb\">3. \u81ea\u52d5\u5316\u6062\u5fa9\u6d41\u7a0b<\/h3>\n<p>\u901a\u904e\u81ea\u52d5\u5316\u5de5\u5177\u548c\u8173\u672c\uff0c\u53ef\u4ee5\u7c21\u5316\u6062\u5fa9\u904e\u7a0b\uff0c\u6e1b\u5c11\u4eba\u5de5\u5e72\u9810\u7684\u9700\u8981\u3002\u9019\u4e0d\u50c5\u63d0\u9ad8\u4e86\u6548\u7387\uff0c\u9084\u964d\u4f4e\u4e86\u932f\u8aa4\u7684\u98a8\u96aa\u3002<\/p>\n<pre><code>#!\/bin\/bash\n# \u81ea\u52d5\u5316\u6578\u64da\u5eab\u6062\u5fa9\u8173\u672c\npg_restore -U username -d my_database my_backup.dump\n<\/code><\/pre>\n<h2 id=\"%e6%81%a2%e5%be%a9%e5%be%8c%e7%9a%84%e6%aa%a2%e6%9f%a5-FuMotXxseb\">\u6062\u5fa9\u5f8c\u7684\u6aa2\u67e5<\/h2>\n<p>\u5728\u5b8c\u6210\u6578\u64da\u5eab\u6062\u5fa9\u5f8c\uff0c\u9032\u884c\u7cfb\u7d71\u6aa2\u67e5\u662f\u5fc5\u4e0d\u53ef\u5c11\u7684\u3002\u9019\u5305\u62ec\u9a57\u8b49\u6578\u64da\u7684\u5b8c\u6574\u6027\u3001\u6aa2\u67e5\u7cfb\u7d71\u6027\u80fd\u4ee5\u53ca\u78ba\u4fdd\u6240\u6709\u61c9\u7528\u7a0b\u5e8f\u6b63\u5e38\u904b\u884c\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u67e5\u8a62\u4f86\u6aa2\u67e5\u6578\u64da\u5b8c\u6574\u6027\uff1a<\/p>\n<pre><code>SELECT COUNT(*) FROM my_table;\n<\/code><\/pre>\n<h2 id=\"%e7%b5%90%e8%ab%96-FuMotXxseb\">\u7d50\u8ad6<\/h2>\n<p>\u5feb\u901f\u7684\u96f2\u6578\u64da\u5eab\u6062\u5fa9\u662f\u78ba\u4fdd\u696d\u52d9\u9023\u7e8c\u6027\u548c\u6578\u64da\u5b89\u5168\u7684\u91cd\u8981\u7d44\u6210\u90e8\u5206\u3002\u901a\u904e\u5b9a\u671f\u5099\u4efd\u3001\u5229\u7528\u5feb\u7167\u548c\u65e5\u8a8c\u6062\u5fa9\u6280\u8853\uff0c\u4ee5\u53ca\u81ea\u52d5\u5316\u6062\u5fa9\u6d41\u7a0b\uff0c\u4f01\u696d\u53ef\u4ee5\u6709\u6548\u5730\u6e1b\u5c11\u6578\u64da\u4e1f\u5931\u5e36\u4f86\u7684\u5f71\u97ff\u3002\u96a8\u8457\u96f2\u6280\u8853\u7684\u767c\u5c55\uff0c\u9019\u4e9b\u6062\u5fa9\u65b9\u6cd5\u5c07\u8b8a\u5f97\u66f4\u52a0\u9ad8\u6548\u548c\u53ef\u9760\u3002<\/p>\n<p>\u5982\u9700\u4e86\u89e3\u66f4\u591a\u6709\u95dc\u96f2\u6578\u64da\u5eab\u548c\u5176\u4ed6\u76f8\u95dc\u670d\u52d9\u7684\u4fe1\u606f\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9 <a href=\"https:\/\/server.hk\">Server.HK<\/a>\uff0c\u63a2\u7d22\u6211\u5011\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\u548c\u5176\u4ed6\u96f2\u670d\u52d9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3\u5982\u4f55\u5feb\u901f\u6062\u5fa9\u96f2\u6578\u64da\u5eab\uff0c\u638c\u63e1\u6709\u6548\u7684\u6b65\u9a5f\u548c\u6280\u5de7\uff0c\u78ba\u4fdd\u6578\u64da\u5b89\u5168\u8207\u696d\u52d9\u9023\u7e8c\u6027\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-174437","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/174437","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=174437"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/174437\/revisions"}],"predecessor-version":[{"id":174438,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/174437\/revisions\/174438"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=174437"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=174437"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=174437"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}