{"id":267257,"date":"2023-03-19T06:03:23","date_gmt":"2023-03-18T22:03:23","guid":{"rendered":"https:\/\/lrxjmw.cn\/qsbfwjzwldbm.html"},"modified":"2023-03-19T06:03:23","modified_gmt":"2023-03-18T22:03:23","slug":"qsbfwjzwldbm","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/qsbfwjzwldbm.html","title":{"rendered":"\u8f7b\u677e\u5907\u4efd\u6587\u4ef6\uff0c\u638c\u63e1Linux tar\u6253\u5305\u547d\u4ee4\u6280\u5de7"},"content":{"rendered":"

\u5728\u5982\u4eca\u4fe1\u606f\u7206\u70b8\u7684\u65f6\u4ee3\uff0c\u6570\u636e\u7684\u91cd\u8981\u6027\u4e0d\u8a00\u800c\u55bb\u3002\u4e3a\u4e86\u66f4\u597d\u5730\u4fdd\u62a4\u6570\u636elinux tar\u6253\u5305\u547d\u4ee4<\/a><\/strong>\uff0c\u5907\u4efd\u663e\u5f97\u5c24\u4e3a\u5fc5\u8981\u3002\u800c\u5bf9\u4e8elinux\u7cfb\u7edf<\/a>\u7528\u6237\u6765\u8bf4\uff0ctar\u547d\u4ee4\u5c31\u662f\u4e00\u4e2a\u975e\u5e38\u5b9e\u7528\u7684\u5de5\u5177\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecdlinux tar\u6253\u5305\u547d\u4ee4<\/strong>\u7684\u4f7f\u7528\u65b9\u6cd5\u53ca\u76f8\u5173\u6280\u5de7\uff0c\u8ba9\u60a8\u8f7b\u677e\u5907\u4efd\u6587\u4ef6\u3002<\/p>\n

1. tar\u547d\u4ee4\u7b80\u4ecb<\/p>\n

tar\u662f\u4e00\u79cd\u5728Unix\u548c\u7c7bUnix\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u5e7f\u6cdb\u4f7f\u7528\u7684\u6253\u5305\u5de5\u5177\u3002\u5b83\u53ef\u4ee5\u5c06\u591a\u4e2a\u6587\u4ef6\u6253\u5305\u6210\u4e00\u4e2a\u5f52\u6863\u6587\u4ef6linux \u5220\u9664\u6587\u4ef6\u5939\uff0c\u5e76\u4e14\u53ef\u4ee5\u901a\u8fc7\u89e3\u538b\u7f29\u8fd8\u539f\u539f\u59cb\u6587\u4ef6\u3002tar\u662f“tape archive”\u7684\u7f29\u5199\uff0c\u6700\u521d\u662f\u4e3a\u4e86\u65b9\u4fbf\u78c1\u5e26\u5b58\u50a8\u800c\u5f00\u53d1\u7684\u3002<\/p>\n

2. tar\u547d\u4ee4\u57fa\u672c\u8bed\u6cd5<\/p>\n

tar\u547d\u4ee4\u7684\u57fa\u672c\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n

tar [\u9009\u9879][\u6587\u4ef6\/\u76ee\u5f55\u540d]<\/p>\n

\u5176\u4e2d\u9009\u9879\u4e3b\u8981\u6709\u4ee5\u4e0b\u51e0\u79cd\uff1a<\/p>\n

-c\uff1a\u521b\u5efa\u65b0\u5f52\u6863\u6587\u4ef6\uff1b<\/p>\n

-x\uff1a\u4ece\u5f52\u6863\u6587\u4ef6\u4e2d\u63d0\u53d6\u6587\u4ef6\uff1b<\/p>\n

-t\uff1a\u5217\u51fa\u5f52\u6863\u6587\u4ef6\u4e2d\u7684\u5185\u5bb9\uff1b<\/p>\n

-r\uff1a\u5411\u73b0\u6709\u5f52\u6863\u6587\u4ef6\u4e2d\u8ffd\u52a0\u65b0\u6587\u4ef6\uff1b<\/p>\n

-u\uff1a\u66f4\u65b0\u5df2\u5b58\u5728\u7684\u5f52\u6863\u6587\u4ef6\u4e2d\u7684\u6587\u4ef6\uff1b<\/p>\n

-f\uff1a\u6307\u5b9a\u5f52\u6863\u6587\u4ef6\u540d\u3002<\/p>\n

3.\u6253\u5305\u5355\u4e2a\u6587\u4ef6<\/p>\n

\u5982\u679c\u9700\u8981\u5907\u4efd\u5355\u4e2a\u6587\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

tar -czvf file.tar.gz \/path\/to\/file<\/p>\n

\u5176\u4e2d\uff0c“c”\u8868\u793a\u521b\u5efa\u65b0\u5f52\u6863RED HAT LINUX 9.0\uff0c“z”\u8868\u793a\u4f7f\u7528gzip\u538b\u7f29\uff0c“v”\u8868\u793a\u663e\u793a\u8be6\u7ec6\u4fe1\u606f\uff0c“f”\u8868\u793a\u6307\u5b9a\u5f52\u6863\u6587\u4ef6\u540d\u3002<\/p>\n

4.\u6253\u5305\u76ee\u5f55<\/p>\n

\u5982\u679c\u9700\u8981\u5907\u4efd\u6574\u4e2a\u76ee\u5f55\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

tar -czvf dir.tar.gz \/path\/to\/dir<\/p>\n

\u5176\u4e2d\uff0c“c”\u8868\u793a\u521b\u5efa\u65b0\u5f52\u6863\uff0c“z”\u8868\u793a\u4f7f\u7528gzip\u538b\u7f29\uff0c“v”\u8868\u793a\u663e\u793a\u8be6\u7ec6\u4fe1\u606f\uff0c“f”\u8868\u793a\u6307\u5b9a\u5f52\u6863\u6587\u4ef6\u540d\u3002<\/p>\n

5.\u6392\u9664\u67d0\u4e9b\u6587\u4ef6\u6216\u76ee\u5f55<\/p>\n

\u6709\u65f6\u5019\u6211\u4eec\u5e76\u4e0d\u60f3\u5907\u4efd\u67d0\u4e9b\u65e0\u7528\u6216\u654f\u611f\u7684\u6587\u4ef6\u6216\u76ee\u5f55\uff0c\u53ef\u4ee5\u4f7f\u7528“--exclude”\u53c2\u6570\u6765\u6392\u9664\u5b83\u4eec\u3002<\/p>\n

\u4f8b\u5982\uff0c\u6392\u9664“dir1”\u7684\u5907\u4efd\uff1a<\/p>\n

tar -czvf backup.tar.gz --exclude=dir1 \/path\/to\/dir<\/p>\n

6.\u538b\u7f29\u7ea7\u522b\u8c03\u6574<\/p>\n

\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0ctar\u4f1a\u91c7\u7528gzip\u538b\u7f29\u7b97\u6cd5\u8fdb\u884c\u538b\u7f29\u3002\u4f46\u662f\u6211\u4eec\u4e5f\u53ef\u4ee5\u4f7f\u7528\u5176\u4ed6\u538b\u7f29\u7b97\u6cd5\uff0c\u5e76\u4e14\u53ef\u4ee5\u8c03\u6574\u538b\u7f29\u7ea7\u522b\u3002<\/p>\n

\u4f8b\u5982\uff0c\u91c7\u7528bzip2\u8fdb\u884c\u538b\u7f29\uff0c\u5e76\u8bbe\u7f6e\u6700\u9ad8\u7ea7\u522b\uff1a<\/p>\n

tar -cjvf backup.tar.bz2 \/path\/to\/dir --bzip2 -9<\/p>\n

linux\u4e0b\u7684tar\u538b\u7f29\u547d\u4ee4_linux\u538b\u7f29\u6587\u4ef6\u5939\u547d\u4ee4 tar_linux tar\u6253\u5305\u547d\u4ee4<\/p>\n

7.\u5206\u5377\u5907\u4efd<\/p>\n

\u5bf9\u4e8e\u6bd4\u8f83\u5927\u7684\u5907\u4efd\u6570\u636e\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u5176\u5206\u5377\u5907\u4efd\u5230\u591a\u4e2a\u5b58\u50a8\u4ecb\u8d28\u4e0a\u3002<\/p>\n

\u4f8b\u5982linux tar\u6253\u5305\u547d\u4ee4<\/strong>\uff0c\u5c06backup.tar.gz\u5206\u6210100MB\u4e00\u5377\uff1a<\/p>\n

tar -czvf -\/path\/to\/backup | split -b 100m - backup.tar.gz.<\/p>\n

8.\u89e3\u538b\u7f29<\/p>\n

\u5982\u679c\u9700\u8981\u4ece\u5df2\u7ecf\u5b58\u5728\u7684\u5f52\u6863\u6587\u4ef6\u4e2d\u63d0\u53d6\u51fa\u67d0\u4e9b\u6216\u5168\u90e8\u5185\u5bb9\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

\u89e3\u538btgz\u683c\u5f0f\uff1a<\/p>\n

linux\u4e0b\u7684tar\u538b\u7f29\u547d\u4ee4_linux\u538b\u7f29\u6587\u4ef6\u5939\u547d\u4ee4 tar_linux tar\u6253\u5305\u547d\u4ee4<\/p>\n

tar -xzvf file.tar.gz<\/p>\n

\u89e3\u538bbz2\u683c\u5f0f\uff1a<\/p>\n

tar -xjvf file.tar.bz2<\/p>\n

9.\u5176\u4ed6\u5e38\u7528\u53c2\u6570<\/p>\n

\u9664\u4e86\u4ee5\u4e0a\u4ecb\u7ecd\u7684\u53c2\u6570\u4e4b\u5916\uff0c\u8fd8\u6709\u5176\u4ed6\u5e38\u7528\u53c2\u6570\u3002<\/p>\n

\u4f8b\u5982\uff0c“-p”\u53c2\u6570\u53ef\u4ee5\u4fdd\u7559\u6743\u9650\u3001\u6240\u6709\u6743\u548c\u65f6\u95f4\u6233\u7b49\u5143\u6570\u636e\u4fe1\u606f\uff1b“--anchored”\u53c2\u6570\u53ea\u5339\u914d\u5f53\u524d\u76ee\u5f55\u4e0b\u4e0e\u6a21\u5f0f\u5339\u914d\u7684\u5185\u5bb9\u3002<\/p>\n

10.\u603b\u7ed3<\/p>\n

\u901a\u8fc7\u672c\u6587\u5bf9linux tar\u6253\u5305\u547d\u4ee4<\/strong>\u7684\u8be6\u7ec6\u4ecb\u7ecd\u548c\u793a\u8303\u5e94\u7528\uff0c\u76f8\u4fe1\u5927\u5bb6\u5df2\u7ecf\u638c\u63e1\u4e86\u57fa\u672c\u64cd\u4f5c\u548c\u76f8\u5173\u6280\u5de7\u3002\u5728\u65e5\u5e38\u5de5\u4f5c\u4e2d\u7075\u6d3b\u8fd0\u7528\u8fd9\u4e9b\u77e5\u8bc6\u70b9\uff0c\u80fd\u591f\u66f4\u52a0\u9ad8\u6548\u5730\u5b8c\u6210\u6570\u636e\u5907\u4efd\u548c\u6062\u590d\u5de5\u4f5c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u800c\u5bf9\u4e8elinux\u7cfb\u7edf\u7528\u6237\u6765\u8bf4\uff0ctar\u547d\u4ee4\u5c31\u662f\u4e00\u4e2a\u975e\u5e38\u5b9e\u7528\u7684\u5de5\u5177\u3002tar\u6253\u5305\u547d\u4ee4\u7684\u4f7f\u7528\u65b9\u6cd5\u53ca\u76f8\u5173\u6280\u5de7\uff0c\u8ba9\u60a8\u8f7b\u677e\u5907\u4efd\u6587\u4ef6\u3002tar\u547d\u4ee4\u57fa\u672c\u8bed\u6cd5tar\u547d\u4ee4\u7684\u57fa\u672c\u8bed\u6cd5\u5982\u4e0b\uff1a\u5982\u679c\u9700\u8981\u5907\u4efd\u5355\u4e2a\u6587\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a\u5982\u679c\u9700\u8981\u5907\u4efd\u6574\u4e2a\u76ee\u5f55\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1atar\u6253\u5305\u547d\u4ee4\u7684\u8be6\u7ec6\u4ecb\u7ecd\u548c\u793a\u8303\u5e94\u7528\uff0c\u76f8\u4fe1\u5927\u5bb6\u5df2\u7ecf\u638c\u63e1\u4e86\u57fa\u672c\u64cd\u4f5c\u548c\u76f8\u5173\u6280\u5de7\u3002<\/p>\n","protected":false},"author":1,"featured_media":267258,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[988],"tags":[999],"class_list":["post-267257","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tougao","tag-999"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/267257","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=267257"}],"version-history":[{"count":0,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/267257\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/267258"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=267257"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=267257"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=267257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}