{"id":3497,"date":"2005-04-07T15:53:57","date_gmt":"2005-04-07T07:53:57","guid":{"rendered":"https:\/\/2blog.ilc.edu.tw\/176\/2005\/04\/07\/%e8%b3%87%e6%96%99%e5%82%99%e4%bb%bd%e6%96%b9%e6%b3%95\/"},"modified":"2021-03-18T19:55:23","modified_gmt":"2021-03-18T11:55:23","slug":"%e8%b3%87%e6%96%99%e5%82%99%e4%bb%bd%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/2blog.ilc.edu.tw\/linkc\/2005\/04\/07\/%e8%b3%87%e6%96%99%e5%82%99%e4%bb%bd%e6%96%b9%e6%b3%95\/","title":{"rendered":"\u8cc7\u6599\u5099\u4efd\u65b9\u6cd5"},"content":{"rendered":"<p>\u4e00.\u4f7f\u7528 tar \u53ca \u58d3\u7e2e\u7a0b\u5f0f<br \/>\n\u4f8b\u5982:<br \/>\n1.\u8981\u5099\u4efd \/etc \u9019\u500b\u76ee\u9304, \u53ef\u4ee5\u5982\u6b64\u505a: tar cf etc.tar \/etc<br \/>\n(c \u662f\u958b\u8a2d\u4e00\u500b\u65b0\u6a94, f \u662f\u6307\u5b9a\u6a94\u540d\u4e4b\u610f)<\/p>\n<p>2.\u82e5\u60a8\u8981\u591a\u52a0\u4e00\u9053\u9a57\u8b49\u7684\u52d5\u4ef6, \u53ef\u591a\u52a0\u500b W \u9078\u9805: tar cWf etc.tar \/etc<\/p>\n<p>3.\u82e5\u8981\u8a73\u7d30\u986f\u793a, \u53ef\u591a\u52a0\u500b v \u9078\u9805: tar cvf etc.tar \/etc<\/p>\n<p>4.\u82e5\u8981\u6253\u5305\u4e4b\u5f8c, \u518d\u884c\u58d3\u7e2e, \u53ef\u591a\u52a0\u500b z \u9078\u9805: tar cvzf etc.tar.gz \/etc<br \/>[@more@]\u4e8c.tar\u9032\u968e\u4f7f\u7528:<\/p>\n<p>\u5c0d\u65bc\u5099\u4efd\u6a94\u61c9\u8a72\u52a0\u8a3b\u65e5\u671f, \u9019\u500b\u53ef\u4ee5\u900f\u904e date +\u6642\u9593\u683c\u5f0f \u9019\u500b\u6307\u4ee4\u9054\u6210\u3002<br \/>\u4f8b\u5982:<br \/>1.tar cvf etc.`date +%d%H%M%S`.tar \/etc<br \/>\u00a0\u00a0 \u7d50\u679c\u53ef\u80fd\u6703\u662f: etc.17144055.tar<\/p>\n<p>2. \u8a18\u9304\u672c\u6b21\u5099\u4efd(\u7b2c\u4e00\u6b21\u5168\u90e8\u5099\u4efd)\u4e4b\u6642\u9593: touch bkup_last_time<br \/>\u00a0\u00a0\u00a0 *\u4e0b\u6b21\u5099\u4efd \/etc \u76ee\u9304\u6642, \u4e0d\u5168\u90e8\u5099\u4efd, \u53ea\u5099\u4efd\u7570\u52d5\u6a94, \u65b9\u6cd5\u5982\u4e0b:<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 find \/etc -cnewer bkup_last_time &gt; newbk.lst<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 tar cvf etc.newer.tar -T newbk.lst<\/p>\n<p>\u00a0\u00a0 * \u8a18\u9304\u672c\u6b21\u5099\u4efd\u4e4b\u6642\u9593: touch bkup_last_time<br \/>\u00a0\u00a0 * \u4e0b\u6b21\u5099\u4efd\u6642\u518d\u91cd\u8986\u4e0a\u8ff0\u6b65\u9a5f.<\/p>\n<p>\u4e09.\u5099\u4efd\u76ee\u9304:<\/p>\n<p>\u00a0 \u5efa\u8b70 \/etc, \/home, \/var\/spool\/mail \u53ca\u8cc7\u6599\u5eab\u7b49\u76ee\u9304\u5373\u662f\u5fc5\u9808\u5099\u4efd\u7684, \u5176\u5b83\u5c31\u8996\u60a8\u800c\u5b9a, \u81ea\u7531\u6289\u64c7\u56c9.<br \/><font size=\"4\">\u5099\u4efd\u53e6\u4e00\u500b\u65b9\u6cd5:<\/font><br \/>\u00a0php script<br \/>\u53ea\u9700\u8981\u4f9d\u500b\u4eba\u6240\u9700\u66f4\u6539 4SOURCE_DIR \u548c $EXCLUDE_D \u6700\u5f8c\u518d chmod +x \u5c31\u53ef\u4ee5\u4e86\u3002<br \/>\u5982\u679c\u8981\u653e crontab,\u5c07 $ask = strtolower(read());<br \/>\u62ff\u6389\u5c31\u53ef\u4ee5\u4e86<\/p>\n<p><span><br \/>#!\/usr\/bin\/php -q<br \/>&lt;?php<br \/>\/\/Change The following two variables<br \/>$SOURCE_DIR = &quot;\/bin \/boot \/etc \/home \/lib \/mnt \/opt \/root \/sbin \/tmp \/usr \/var&quot;;<br \/>$EXCLUDE_D = &quot;\/home\/benny\/mnt \/usr\/portage\/distfiles&quot;;<br \/>\/\/Stop here unless you know what you&#8217;re doing<br \/>$EXCLUDE_DIR = explode(&quot; &quot;,$EXCLUDE_D);<br \/>$DEST_DIR = &quot;\/misc\/backup&quot;;<br \/>$DATE = date(&quot;Y-m-d&quot;);<br \/>$FILE = &quot;BACKUP-&quot;.$DATE.&quot;.tgz&quot;;<br \/>for ( $i = 0; $i &lt; count($EXCLUDE_DIR); $i++ ) {<br \/> if ( !$EXCLUDE ) { $EXCLUDE = &quot; &#8211;exclude=&quot;.$EXCLUDE_DIR[$i]; }<br \/> else { $EXCLUDE = $EXCLUDE.&quot; &#8211;exclude=&quot;.$EXCLUDE_DIR[$i]; }<br \/>}<br \/>$BACKUP = &quot;tar -zcvf &quot;.$DEST_DIR.&quot;\/&quot;.$FILE.&quot; &quot;.$SOURCE_DIR.$EXCLUDE;<br \/>function read() {<br \/> $fp = fopen(&quot;<a href=\"http:\/\/stdin%22\/\" target=\"_blank\" rel=\"noopener noreferrer\">php:\/\/stdin&quot;<\/a>,&quot;r&quot;);<br \/> $input = fgets($fp,255);<br \/> fclose($fp);<br \/> return eregi_replace(&quot;n&quot;,&quot;&quot;,$input);<br \/>}<br \/>echo &quot;=-= System Backup =-=nDESTINATION PATH: &quot;<br \/> .$DEST_DIR.&quot;nFILE: &quot;.$FILE.<br \/> &quot;nExcluding: $EXCLUDE_Dn&quot;.<br \/> &quot;nProceed? [Y\/n]: &quot;;<\/p>\n<p>$ask = strtolower(read());<br \/>if ( !$ask ) { $ask = &quot;y&quot;; }<br \/>if ( $ask == &quot;y&quot; ) {<br \/> echo &quot;System Backup will start within 5 Secsn&quot;;<br \/> for ( $i=0; $i&lt;5; $i++ ) {<br \/> echo 5-$i.&quot;n&quot;;<br \/> sleep(1);<br \/> }<br \/> echo &quot;Initializing System Backup&#8230;n&quot;;<br \/> shell_exec(&quot;echo Starting @ `date` &gt;&gt; backup.log&quot;);<br \/> shell_exec(&quot;echo Filename: $FILE &gt;&gt; backup.log&quot;);<br \/> shell_exec(&quot;$BACKUP&quot;);<br \/> shell_exec(&quot;echo Completed @ `date` &gt;&gt; backup.log&quot;);<br \/>}<br \/>else { echo &quot;Aborted!n&quot;; }<br \/>?&gt;<\/span><\/p>\n<p> <a name=\"comments\"><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00.\u4f7f\u7528 tar \u53ca \u58d3\u7e2e\u7a0b\u5f0f \u4f8b\u5982: 1.\u8981\u5099\u4efd \/etc \u9019\u500b\u76ee\u9304, \u53ef\u4ee5\u5982\u6b64\u505a: tar cf etc. [&hellip;]<\/p>\n","protected":false},"author":58,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"","ocean_second_sidebar":"","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"","ocean_custom_header_template":"","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"","ocean_menu_typo_font_family":"","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"","ocean_post_oembed":"","ocean_post_self_hosted_media":"","ocean_post_video_embed":"","ocean_link_format":"","ocean_link_format_target":"self","ocean_quote_format":"","ocean_quote_format_link":"post","ocean_gallery_link_images":"on","ocean_gallery_id":[],"footnotes":""},"categories":[53],"tags":[],"class_list":["post-3497","post","type-post","status-publish","format-standard","hentry","category-c-449","entry"],"meta_key":{"lt_post_id":["1412"]},"_links":{"self":[{"href":"https:\/\/2blog.ilc.edu.tw\/linkc\/wp-json\/wp\/v2\/posts\/3497"}],"collection":[{"href":"https:\/\/2blog.ilc.edu.tw\/linkc\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/2blog.ilc.edu.tw\/linkc\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/2blog.ilc.edu.tw\/linkc\/wp-json\/wp\/v2\/users\/58"}],"replies":[{"embeddable":true,"href":"https:\/\/2blog.ilc.edu.tw\/linkc\/wp-json\/wp\/v2\/comments?post=3497"}],"version-history":[{"count":1,"href":"https:\/\/2blog.ilc.edu.tw\/linkc\/wp-json\/wp\/v2\/posts\/3497\/revisions"}],"predecessor-version":[{"id":4026,"href":"https:\/\/2blog.ilc.edu.tw\/linkc\/wp-json\/wp\/v2\/posts\/3497\/revisions\/4026"}],"wp:attachment":[{"href":"https:\/\/2blog.ilc.edu.tw\/linkc\/wp-json\/wp\/v2\/media?parent=3497"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/2blog.ilc.edu.tw\/linkc\/wp-json\/wp\/v2\/categories?post=3497"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/2blog.ilc.edu.tw\/linkc\/wp-json\/wp\/v2\/tags?post=3497"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}