{"id":24123,"date":"2025-04-19T09:26:37","date_gmt":"2025-04-19T01:26:37","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/24123.html"},"modified":"2025-04-19T09:26:37","modified_gmt":"2025-04-19T01:26:37","slug":"%e5%88%a9%e7%94%a8rsync%e5%a4%87%e4%bb%bd%e5%85%a8%e7%bd%91%e6%9c%8d%e5%8a%a1%e5%99%a8%e6%95%b0%e6%8d%ae","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/24123.html","title":{"rendered":"\u5229\u7528rsync\u5907\u4efd\u5168\u7f51\u670d\u52a1\u5668\u6570\u636e"},"content":{"rendered":"<h2>\u4e00\u3001\u9879\u76ee\u63cf\u8ff0<\/h2>\n<p>\u67d0\u516c\u53f8\u91cc\u6709\u4e00\u53f0Web\u670d\u52a1\u5668&#xff0c;\u91cc\u9762\u7684\u6570\u636e\u5f88\u91cd\u8981&#xff0c;\u4f46\u662f\u5982\u679c\u786c\u76d8\u574f\u4e86\u6570\u636e\u5c31\u4f1a\u4e22\u5931&#xff0c;\u73b0\u5728\u9886\u5bfc\u8981\u6c42\u628a\u6570\u636e\u505a\u5907\u4efd&#xff0c;\u8fd9\u6837Web\u670d\u52a1\u5668\u6570\u636e\u4e22\u5931\u5728\u53ef\u4ee5\u8fdb\u884c\u6062\u590d&#xff0c;\u8981\u6c42\u5982\u4e0b&#xff1a;<\/p>\n<p>1\u3001\u5907\u4efd\u8981\u6c42<\/p>\n<p>\u6bcf\u5929\u665a\u4e0a00\u70b9\u6574\u5728Web\u670d\u52a1\u5668\u4e0a\u6253\u5305\u5907\u4efd\u7cfb\u7edf\u914d\u7f6e\u6587\u4ef6\u3001\u7f51\u7ad9\u7a0b\u5e8f\u76ee\u5f55\u53ca\u8bbf\u95ee\u65e5\u5fd7\u5e76\u901a\u8fc7rsync\u547d\u4ee4\u63a8\u9001\u5230Rsync\u5907\u4efd\u670d\u52a1\u5668\u4e0a\u5907\u4efd\u4fdd\u7559\u3002<\/p>\n<p>2\u3001\u5907\u4efd\u601d\u8def<\/p>\n<p>\u53ef\u4ee5\u662f\u5148\u5728\u672c\u5730\u6309\u65e5\u671f\u6253\u5305&#xff0c;\u7136\u540e\u518d\u63a8\u9001\u5230Rsync\u5907\u4efd\u670d\u52a1\u5668\u4e0a&#xff1b;NFS\u5b58\u50a8\u670d\u52a1\u5668\u548cWeb\u670d\u52a1\u5668\u5728\u5b9e\u9645\u5de5\u4f5c\u4e2d\u5c31\u662f\u8fd0\u7ef4\u4e3b\u8981\u7ba1\u7406\u7684\u5168\u90e8\u670d\u52a1\u5668\u3002<\/p>\n<h3>\u4e8c\u3001\u73af\u5883\u8bf4\u660e<\/h3>\n<p>\u9700\u8981\u4e09\u53f0\u670d\u52a1\u5668\u4e3b\u673a&#xff0c;\u5176\u4e3b\u673a\u4fe1\u606f\u5982\u4e0b&#xff1a;<\/p>\n<table border=\"1\" cellpadding=\"1\" cellspacing=\"1\" style=\"width:500px\">\n<tbody>\n<tr>\n<td>\u670d\u52a1\u5668\u8bf4\u660e<\/td>\n<td>\u4e3b\u673a\u540d\u79f0<\/td>\n<td>IP\u5730\u5740<\/td>\n<\/tr>\n<tr>\n<td>Nginx web\u670d\u52a1\u5668<\/td>\n<td>openEuler-1<\/td>\n<td>192.168.121.11<\/td>\n<\/tr>\n<tr>\n<td>NFS\u5b58\u50a8\u670d\u52a1\u5668<\/td>\n<td>openEuler-2<\/td>\n<td>192.168.121.12<\/td>\n<\/tr>\n<tr>\n<td>Rsync\u5907\u4efd\u670d\u52a1\u5668<\/td>\n<td>openEuler-3<\/td>\n<td>192.168.121.12<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u4e09\u3001\u9879\u76ee\u5907\u4efd\u9700\u6c42<\/h2>\n<p>&#xff08;1&#xff09;\u6240\u6709\u670d\u52a1\u5668\u7684\u5907\u4efd\u76ee\u5f55\u5fc5\u987b\u90fd\u4e3a\/backup\u3002 &#xff08;2&#xff09;\u8981\u5907\u4efd\u7684\u7cfb\u7edf\u914d\u7f6e\u6587\u4ef6\u5305\u62ec\u4f46\u4e0d\u9650\u4e8e&#xff1a;<\/p>\n<ul>\n<li>\u5b9a\u65f6\u4efb\u52a1\u670d\u52a1\u7684\u914d\u7f6e\u6587\u4ef6&#xff08;\/var\/spool\/cron\/root&#xff09; \u00a0&#xff08;\u9002\u5408Web\u548cNFS\u670d\u52a1\u5668&#xff09;\u3002<\/li>\n<li>\u5f00\u673a\u81ea\u542f\u52a8\u7684\u914d\u7f6e\u6587\u4ef6&#xff08;\/etc\/rc.local&#xff09; \u00a0&#xff08;\u9002\u5408Web\u548cNFS\u670d\u52a1\u5668&#xff09;\u3002<\/li>\n<li>\u65e5\u5e38\u811a\u672c\u7684\u76ee\u5f55 \u00a0&#xff08;\/server\/script&#xff09;\u3002<\/li>\n<\/ul>\n<p>&#xff08;3&#xff09;Web\u670d\u52a1\u5668\u7ad9\u70b9\u76ee\u5f55\u5047\u5b9a\u4e3a\/var\/www\/html\/&#xff0c;\u5982\u679c\u6ca1\u6709&#xff0c;\u53ef\u4ee5\u5148\u6a21\u62df\u521b\u5efa\u3002 &#xff08;4&#xff09;Web\u670d\u52a1\u5668\u8bbf\u95ee\u65e5\u5fd7\u8def\u5f84\u5047\u5b9a\u4e3a\/app\/logs&#xff0c;\u5982\u679c\u6ca1\u6709&#xff0c;\u53ef\u4ee5\u5148\u6a21\u62df\u521b\u5efa\u3002 &#xff08;5&#xff09;Web\u670d\u52a1\u5668\u672c\u5730\u4fdd\u7559\u6253\u5305\u540e\u76847\u5929\u5907\u4efd\u6570\u636e\u5373\u53ef&#xff08;\u672c\u5730\u7559\u5b58\u4e0d\u80fd\u591a\u4e8e7\u5929&#xff0c;\u56e0\u4e3a\u6570\u636e\u592a\u591a\u786c\u76d8\u4f1a\u6ee1&#xff09;\u3002 &#xff08;6&#xff09;\u5907\u4efd\u670d\u52a1\u5668BACKUP\u4e0a&#xff0c;\u4fdd\u7559\u6700\u8fd17\u5929\u6240\u6709\u5907\u4efd\u6570\u636e&#xff0c;\u4fdd\u75596\u4e2a\u6708\u5185\u6bcf\u5468\u4e00\u7684\u6240\u6709\u6570\u636e\u526f\u672c\u3002 &#xff08;7&#xff09;\u5907\u4efd\u670d\u52a1\u5668\u4e0a&#xff0c;\u8981\u6309\u7167\u5907\u4efd\u6570\u636e\u670d\u52a1\u5668\u5185\u7f51IP\u4e3a\u76ee\u5f55\u4fdd\u5b58\u5907\u4efd&#xff0c;\u5907\u4efd\u7684\u6587\u4ef6\u6309\u7167\u65f6\u95f4\u3001\u540d\u79f0\u4fdd\u5b58\u3002 &#xff08;8&#xff09;\u9700\u8981\u786e\u4fdd\u5907\u4efd\u7684\u6570\u636e\u5c3d\u91cf\u5b8c\u6574\u51c6\u786e&#xff0c;\u5728\u5907\u4efd\u670d\u52a1\u5668\u4e0a\u5bf9\u5907\u4efd\u7684\u6570\u636e\u662f\u5426\u5b8c\u6574\u8fdb\u884c\u68c0\u67e5\u3002 &#xff08;9&#xff09;\u5907\u4efd\u670d\u52a1\u5668BACKUP\u4e0a&#xff0c;\u6bcf\u5929\u65e9\u66688:00\u628a\u5907\u4efd\u6210\u529f\u6216\u5931\u8d25\u7ed3\u679c\u4fe1\u606f\u53d1\u9001\u5230\u7cfb\u7edf\u7ba1\u7406\u5458\u90ae\u7bb1\u91cc\u3002<\/p>\n<table border=\"1\" cellpadding=\"1\" cellspacing=\"1\" style=\"width:500px\">\n<tbody>\n<tr>\n<td>\u670d\u52a1\u5668\u8bf4\u660e<\/td>\n<td>\u5907\u4efd\u76ee\u5f55<\/td>\n<td>\u76ee\u5f55\u8bf4\u660e<\/td>\n<td>\u5907\u6ce8<\/td>\n<\/tr>\n<tr>\n<td>all server<\/td>\n<td>\/backup<\/td>\n<td>\u5907\u4efd\u76ee\u5f55<\/td>\n<td>\u7edf\u4e00\u670d\u52a1\u5668\u672c\u5730\u5907\u4efd\u76ee\u5f55&#xff0c;\u4fbf\u4e8e\u7ba1\u7406<\/td>\n<\/tr>\n<tr>\n<td>all server<\/td>\n<td>\/var\/spool\/cron\/root<\/td>\n<td>\u5b9a\u65f6\u4efb\u52a1\u670d\u52a1\u914d\u7f6e\u6587\u4ef6<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>all server<\/td>\n<td>\/etc\/rc.local<\/td>\n<td>\u5f00\u673a\u81ea\u542f\u52a8\u914d\u7f6e\u6587\u4ef6<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>all server<\/td>\n<td>\/server\/script<\/td>\n<td>\u65e5\u5e38\u811a\u672c\u76ee\u5f55<\/td>\n<td>\u7edf\u4e00\u670d\u52a1\u5668\u672c\u5730\u811a\u672c\u76ee\u5f55&#xff0c;\u4fbf\u4e8e\u7ba1\u7406<\/td>\n<\/tr>\n<tr>\n<td>Web server<\/td>\n<td>\/var\/www\/html<\/td>\n<td>web\u670d\u52a1\u5668\u7ad9\u70b9\u76ee\u5f55<\/td>\n<td>mkdir -p \/var\/www\/html<\/td>\n<\/tr>\n<tr>\n<td>Web server<\/td>\n<td>\/app\/logs<\/td>\n<td>web\u670d\u52a1\u5668\u8bbf\u95ee\u65e5\u5fd7\u8def\u5f84<\/td>\n<td>mkdir -p \/app\/logs<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u56db\u3001\u670d\u52a1\u5668\u7684\u90e8\u7f72<\/h2>\n<p>&#xff08;1&#xff09;Rsync\u5907\u4efd\u670d\u52a1\u5668\u642d\u5efa\u90e8\u7f72&#xff08;openEuler-3&#xff09;<\/p>\n<ul>\n<li>\n<p>rsync\u670d\u52a1\u5668\u642d\u5efa\u90e8\u7f72\u3002<\/p>\n<\/li>\n<li>\n<p>\u5f00\u53d1\u811a\u672c\u5b9e\u73b0\u6821\u9a8c\u3001\u5220\u9664\u3001\u62a5\u8b66\u3002<\/p>\n<\/li>\n<li>\n<p>\u914d\u7f6e\u5b9e\u65f6\u4efb\u52a1\u6bcf\u59296\u70b9\u5b9e\u65f6\u6267\u884c\u3002<\/p>\n<\/li>\n<\/ul>\n<p>&#xff08;2&#xff09;Web\u670d\u52a1\u5668\u642d\u5efa\u90e8\u7f72&#xff08;openEuler-1&#xff09;<\/p>\n<ul>\n<li>\n<p>\u9a8c\u8bc1Rsync\u670d\u52a1\u80fd\u5426\u63a8\u9001\u6210\u529f\u3002<\/p>\n<\/li>\n<li>\n<p>\u5f00\u53d1\u811a\u672c\u5b9e\u73b0\u6253\u5305\u5907\u4efd\u3001\u63a8\u9001\u3001\u6821\u9a8c\u3001\u5220\u9664\u3002<\/p>\n<\/li>\n<li>\n<p>\u914d\u7f6e\u5b9a\u65f6\u4efb\u52a1\u6bcf\u59290\u70b9\u5b9a\u65f6\u63a8\u9001\u3002<\/p>\n<\/li>\n<\/ul>\n<p>&#xff08;3&#xff09;NFS\u5b58\u50a8\u670d\u52a1\u5668\u642d\u5efa\u90e8\u7f72&#xff08;openEuler-2&#xff09;<\/p>\n<ul>\n<li>\n<p>\u9a8c\u8bc1Rsync\u670d\u52a1\u80fd\u5426\u63a8\u9001\u6210\u529f\u3002<\/p>\n<\/li>\n<li>\n<p>\u5f00\u53d1\u811a\u672c\u5b9e\u73b0\u6253\u5305\u5907\u4efd\u3001\u63a8\u9001\u3001\u6821\u9a8c\u3001\u5220\u9664\u3002<\/p>\n<\/li>\n<li>\n<p>\u914d\u7f6e\u5b9a\u65f6\u4efb\u52a1\u6bcf\u59290\u70b9\u5b9a\u65f6\u63a8\u9001\u3002<\/p>\n<\/li>\n<\/ul>\n<h2>\u4e94\u3001\u9879\u76ee\u5b9e\u65bd<\/h2>\n<h3>1\u3001\u5728Rsync\u5907\u4efd\u670d\u52a1\u5668\u4e0a\u90e8\u7f72Rsync\u670d\u52a1<\/h3>\n<p># \u5b89\u88c5rsync<br \/>\n[root&#064;openEuler-3 ~]# yum install -y rsync<\/p>\n<p># \u914d\u7f6e\u6587\u4ef6<br \/>\n[root&#064;openEuler-3 ~]# vim \/etc\/rsyncd.conf<br \/>\n[root&#064;openEuler-3 ~]# cat \/etc\/rsyncd.conf<br \/>\nuid &#061; rsync<br \/>\ngid &#061; rsync<br \/>\nuse chroot &#061; no<br \/>\nmax connections &#061; 200<br \/>\ntimeout &#061; 300<br \/>\npid file &#061; \/var\/run\/rsyncd.pid<br \/>\nlock file &#061; \/var\/run\/rsync.lock<br \/>\nlog file &#061; \/var\/log\/rsyncd.log<br \/>\nfake super &#061; yes<\/p>\n<p>[backup]<br \/>\n        path &#061; \/backup<br \/>\n        ignore errors<br \/>\n        read only &#061; false<br \/>\n        list &#061; false<br \/>\n        hosts allow &#061; 192.168.121.0\/24<br \/>\n        hosts deny &#061; 0.0.0.0\/32<br \/>\n        auth users &#061; rsync_backup<br \/>\n        secrets file &#061; \/etc\/rsync.password<\/p>\n<p># \u521b\u5efarsync\u8d26\u6237\u53ca\u5171\u4eab\u76ee\u5f55\u5e76\u4fee\u6539\u76ee\u5f55\u5c5e\u4e3b\u4e3arsync<br \/>\n[root&#064;openEuler-3 ~]# useradd -M -s \/sbin\/nologin rsync<br \/>\n[root&#064;openEuler-3 ~]# mkdir \/backup<br \/>\n[root&#064;openEuler-3 ~]# chown -R rsync \/backup<\/p>\n<p># \u542f\u52a8\u670d\u52a1<br \/>\n[root&#064;openEuler-3 ~]# systemctl enable &#8211;now rsyncd<br \/>\nCreated symlink \/etc\/systemd\/system\/multi-user.target.wants\/rsyncd.service \u2192 \/usr\/lib\/systemd\/system\/rsyncd.service.<\/p>\n<p># \u521b\u5efarsync\u865a\u62df\u8d26\u6237\u540d\u548c\u5bc6\u7801,\u5e76\u8d4b\u4e88\u5bc6\u7801\u6587\u4ef6600\u6743\u9650<br \/>\n[root&#064;openEuler-3 ~]# echo &#034;rsync_backup:123456&#034; &gt; \/etc\/rsync.password<br \/>\n[root&#064;openEuler-3 ~]# chmod 600 \/etc\/rsync.password<\/p>\n<p>\u89e3\u8bfb\u914d\u7f6e\u6587\u4ef6&#xff1a;<\/p>\n<p>uid &#061; rsync# \u7528\u6237<br \/>\ngid &#061; rsync# \u7ec4<br \/>\nuse chroot &#061; no# \u7a0b\u5e8f\u5b89\u5168\u8bbe\u7f6e<br \/>\nmax connections &#061; 200# \u5ba2\u6237\u7aef\u8fde\u63a5\u6570<br \/>\ntimeout &#061; 300# \u8d85\u65f6\u65f6\u95f4<br \/>\npid file &#061; \/var\/run\/rsyncd.pid# \u8fdb\u7a0b\u53f7\u6587\u4ef6\u4f4d\u7f6e<br \/>\nlock file &#061; \/var\/run\/rsync.lock# \u8fdb\u7a0b\u9501<br \/>\nlog file &#061; \/var\/log\/rsyncd.log# \u65e5\u5fd7\u6587\u4ef6<br \/>\nfake super &#061; yes # \u65e0\u9700rsync\u4ee5root\u8eab\u4efd\u8fd0\u884c&#xff0c;\u5141\u8bb8\u63a5\u53d7\u6570\u636e<\/p>\n<p>[backup]<br \/>\n        path &#061; \/backup# \u76ee\u5f55<br \/>\n        ignore errors# \u6709\u9519\u8bef\u65f6\u5ffd\u7565<br \/>\n        read only &#061; false# \u53ef\u8bfb\u53ef\u5199<br \/>\n        list &#061; false# \u963b\u6b62\u8fdc\u7a0b\u5217\u8868&#xff08;\u4e0d\u8ba9\u901a\u8fc7\u8fdc\u7a0b\u65b9\u5f0f\u770b\u670d\u52a1\u7aef\u6709\u5565&#xff09;<br \/>\n        hosts allow &#061; 192.168.121.0\/24# \u5141\u8bb8IP<br \/>\n        hosts deny &#061; 0.0.0.0\/32# \u7981\u6b62IP<br \/>\n        auth users &#061; rsync_backup# \u865a\u62df\u7528\u6237<br \/>\n        secrets file &#061; \/etc\/rsync.password# \u5b58\u653e\u7528\u6237\u548c\u5bc6\u7801\u7684\u6587\u4ef6 <\/p>\n<h3>2\u3001web\u670d\u52a1\u5668&#xff0c;NFS \u670d\u52a1\u5668\u672c\u5730\u6253\u5305\u5907\u4efd\u811a\u672c\u5b9e\u73b0<\/h3>\n<p># \u5b89\u88c5rsync<br \/>\n[root&#064;openEuler-3 ~]# yum install -y rsync<\/p>\n<p># \u521b\u5efarsync\u5bc6\u7801\u6587\u4ef6&#xff0c;\u65b9\u4fbf\u811a\u672c\u547d\u4ee4\u76f4\u63a5\u5f15\u7528,\u5e76\u8d4b\u4e88\u5bc6\u7801\u6587\u4ef6600\u6743\u9650<br \/>\n[root&#064;openEuler-3 ~]# echo &#034;123456&#034; &gt; \/etc\/rsync.password<br \/>\n[root&#064;openEuler-3 ~]# chmod 600 \/etc\/rsync.password<\/p>\n<p># \u6a21\u62df\u6570\u636e\u521b\u5efa<br \/>\n[root&#064;openEuler-1 script]# touch \/var\/www\/html\/{1..3}.txt<br \/>\n[root&#064;openEuler-1 script]# mkdir -p \/app\/logs<br \/>\n[root&#064;openEuler-1 script]# touch \/app\/logs\/{a..c}.log<\/p>\n<p># \u7f16\u5199\u5907\u4efd\u811a\u672c<br \/>\n[root&#064;openEuler-1 script]# vim backup.sh<br \/>\n[root&#064;openEuler-1 script]# cat backup.sh<br \/>\n#!\/bin\/bash<br \/>\n#########################<br \/>\n#File name:backup.sh<br \/>\n#Email:obboda&#064;163.com<br \/>\n#Created time:2025-01-16 21:07:58<br \/>\n#Description:<br \/>\n#########################<\/p>\n<p>Date&#061;$(date &#043;%F)<br \/>\nHost_IP&#061;$(ifconfig ens160 | awk &#039;\/inet \/{print $2}&#039;)<br \/>\nBackup_Dir&#061;&#034;\/backup\/&#034;<br \/>\nBackup_Server_IP&#061;192.168.121.13<\/p>\n<p># \u521b\u5efa\u6307\u5b9a\u76ee\u5f55<br \/>\n[ ! -d $Backup_Dir\/$Host_IP ] &amp;&amp; mkdir -p $Backup_Dir\/$Host_IP<\/p>\n<p># \u6309\u8981\u6c42\u6253\u5305\u5907\u4efd\u6240\u6709\u672c\u5730\u91cd\u8981\u6587\u4ef6<br \/>\ncd \/ &amp;&amp;\\\\<br \/>\ntar cf ${Backup_Dir}${Host_IP}\/sys_file_bak_${Date}_tar.gz var\/spool\/cron\/root &amp;&amp;\\\\<br \/>\ntar rf ${Backup_Dir}${Host_IP}\/sys_file_bak_${Date}_tar.gz etc\/rc.d\/rc.local &amp;&amp;\\\\<br \/>\ntar rf ${Backup_Dir}${Host_IP}\/sys_file_bak_${Date}_tar.gz server\/script\/ &amp;&amp;\\\\<br \/>\ntar zcf $Backup_Dir$Host_IP\/www_${Date}_tar.gz var\/www\/html\/ &amp;&amp;\\\\<br \/>\ntar zcf $Backup_Dir$Host_IP\/app_logs_${Date}_tar.gz app\/logs\/ &amp;&amp;\\\\<br \/>\n# \u63d0\u793a&#xff1a;\u5728NFS\u670d\u52a1\u5668\u5ba2\u6237\u7aef\u4e0a\u4e0d\u7528\u7f16\u5199\u538b\u7f29Web\u670d\u52a1\u5668\u7684\u7a0b\u5e8f\u4e0e\u65e5\u5fd7\u76ee\u5f55<\/p>\n<p># \u7ed9\u6240\u6709\u5907\u4efd\u7684\u538b\u7f29\u6587\u4ef6\u5efa\u7acb\u6307\u7eb9&#xff0c;\u653e\u5165\u6307\u7eb9\u5e93flag&#xff0c;\u540e\u9762\u4f1a\u9a8c\u8bc1\u5b8c\u6574\u6027<br \/>\nfind ${Backup_Dir:-\/tmp} -type f -name &#034;*${Date}_tar.gz&#034; |xargs md5sum &gt;$Backup_Dir\/$Host_IP\/${Date}.flag<\/p>\n<p># \u628a\u5907\u4efd\u63a8\u9001\u5230\u5907\u4efd\u670d\u52a1\u5668<br \/>\nrsync -az $Backup_Dir rsync_backup&#064;${Backup_Server_IP}::backup &#8211;password-file&#061;\/etc\/rsync.password<\/p>\n<p># \u5220\u96647\u5929\u4ee5\u524d\u7684\u6240\u6709\u672c\u5730\u5907\u4efd\u6570\u636e<br \/>\nfind ${Backup_Dir:-\/tmp} -type f -name &#034;*.tar.gz&#034; -a -name &#034;*flag*&#034; -mtime &#043;7|xargs rm -f<\/p>\n<h3 style=\"background-color:transparent\">3\u3001\u914d\u7f6e\u5b9a\u65f6\u4efb\u52a1<\/h3>\n<p># web\u670d\u52a1\u5668&#xff08;nfs\u670d\u52a1\u5668&#xff09;&#xff1a;\u5b9a\u65f6\u6bcf\u59290&#xff1a;00\u6267\u884c\u5907\u4efd\u811a\u672c<br \/>\n[root&#064;openEuler-1 script]# crontab -e<br \/>\ncrontab: installing new crontab<br \/>\n[root&#064;openEuler-1 script]# crontab -l<br \/>\n00 00 * * * \/bin\/sh \/server\/script\/backup.sh &amp;&gt; \/dev\/null<\/p>\n<p># \u5907\u4efd\u670d\u52a1\u5668&#xff1a;\u7f16\u8f91\u670d\u52a1\u7aef\u5220\u9664\u811a\u672c\u6587\u4ef6<br \/>\n[root&#064;openEuler-3 ~]# mkdir -p \/server\/script<br \/>\n[root&#064;openEuler-3 ~]# cd \/server\/script\/<br \/>\n[root&#064;openEuler-3 script]# vim del_bak_data.sh<br \/>\n[root&#064;openEuler-3 script]# cat del_bak_data.sh<br \/>\n#!\/bin\/bash<\/p>\n<p>Backup_Dir&#061;&#034;\/backup\/&#034;<\/p>\n<p>#\u5220\u96647\u5929\u524d\u7684\u538b\u7f29\u5305\u548cflag\u6587\u4ef6<br \/>\nfind ${Backup_Dir:-\/tmp} -type f  -name &#034;*tar.gz*&#034; -name &#034;*flag*&#034; -mtime &#043;7|xargs rm -f<\/p>\n<p># \u5907\u4efd\u670d\u52a1\u5668&#xff1a;\u914d\u7f6e\u5b9a\u65f6\u4efb\u52a1<br \/>\n[root&#064;openEuler-3 script]# crontab -e<br \/>\ncrontab: installing new crontab<br \/>\n[root&#064;openEuler-3 script]# crontab -l<br \/>\n00 00 * * * \/bin\/sh \/server\/script\/del_bak_data.sh &amp;&gt;\/dev\/null <\/p>\n<h3>4\u3001\u6570\u636e\u4f20\u8f93\u5b8c\u6574\u6027\u9a8c\u8bc1\u4e0e\u76d1\u63a7\u544a\u8b66<\/h3>\n<p># \u5907\u4efd\u670d\u52a1\u5668&#xff1a;\u9488\u5bf9\u5907\u4efd\u65f6\u7684md5\u6307\u7eb9\u6570\u636e&#xff0c;\u5229\u7528MD5\u547d\u4ee4\u8fdb\u884c\u9a8c\u8bc1&#xff0c;\u5b8c\u6210\u6570\u636e\u4f20\u8f93\u8fc7\u7a0b\u5b8c\u6574\u6027\u9a8c\u8bc1.<br \/>\n[root&#064;openEuler-3 script]# vim send_mail.sh<br \/>\n[root&#064;openEuler-3 script]# cat send_mail.sh<br \/>\n#!\/bin\/bash<br \/>\nDate&#061;$(date &#043;%F)<br \/>\nBackup_Dir&#061;&#034;\/backup\/&#034;<br \/>\nCheck_Log&#061;&#034;\/tmp\/bak.log_$(date &#043;%F)&#034;<br \/>\nAdmin_Mail&#061;obboda&#064;163.com<\/p>\n<p>find $Backup_Dir -type f -name &#034;*.flag&#034;|xargs md5sum -c &gt;&gt; $Check_Log<\/p>\n<p>if [ -s &#034;$Check_Log&#034; ]<br \/>\nthen<br \/>\n    mail -s &#034;$Date backup data info&#034; $Admin_Mail &lt;$Check_Log<br \/>\nelse<br \/>\n    echo &#034;$Date backup data error,pls check it.&#034; &gt;$Check_Log<br \/>\n    mail -s &#034;$Date backup data info&#034; $Admin_Mail &lt;$Check_Log<br \/>\nfi<\/p>\n<p>cp $Check_Log{,.ori} &amp;&amp; &gt;$Check_Log<\/p>\n<h3>5\u3001\u914d\u7f6email\u4f7f\u7528\u5916\u90e8SMTP\u53d1\u90ae\u4ef6<\/h3>\n<p># \u5b89\u88c5mailx<br \/>\n[root&#064;openEuler-3 script]# yum install -y mailx<\/p>\n<p># \u7f16\u8f91\/etc\/mail.rc\u914d\u7f6e\u6587\u4ef6&#xff08;\u5728\u6700\u540e\u4e00\u884c\u52a0\u5165&#xff09;<br \/>\n[root&#064;openEuler-3 script]# vim \/etc\/mail.rc<br \/>\n[root&#064;openEuler-3 script]# tail -n5 \/etc\/mail.rc<br \/>\nset from&#061;obboda&#064;163.com<br \/>\nset smtp&#061;smtp.163.com<br \/>\nset smtp-auth-user&#061;obboda&#064;163.com<br \/>\nset smtp-auth-password&#061;********        # \u8fd9\u91cc\u586b\u5199\u81ea\u5df1\u90ae\u7bb1\u7684\u6388\u6743\u7801<br \/>\nset smtp-auth&#061;login<\/p>\n<p># \u6d4b\u8bd5\u53d1\u9001\u90ae\u4ef6<br \/>\n[root&#064;openEuler-3 script]# echo &#034;how are u?&#034; | mail -s &#034;HELLO!&#034; obboda&#064;163.com<\/p>\n<h3>6\u3001\u6700\u540e\u6d4b\u8bd5<\/h3>\n<p># \u624b\u52a8\u6267\u884c\u811a\u672c\u8fdb\u884c\u6d4b\u8bd5<br \/>\n[root&#064;openEuler-1 script]# bash backup.sh<\/p>\n<p># \u67e5\u770b\u5907\u4efd<br \/>\n[root&#064;openEuler-3 script]# tree \/backup\/192.168.121.11\/<br \/>\n\/backup\/192.168.121.11\/<br \/>\n\u251c\u2500\u2500 2025-01-16.flag<br \/>\n\u251c\u2500\u2500 app_logs_2025-01-16_tar.gz<br \/>\n\u251c\u2500\u2500 sys_file_bak_2025-01-16_tar.gz<br \/>\n\u2514\u2500\u2500 www_2025-01-16_tar.gz<\/p>\n<p># \u67e5\u770b\u6821\u9a8c\u7ed3\u679c<br \/>\n[root&#064;openEuler-3 script]# bash send_mail.sh<\/p>\n<p>\u6821\u9a8c\u7ed3\u679c&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"459\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419012635-6802fbcbd7308.png\" width=\"1068\" \/><\/p>\n<p>\u6d4b\u8bd5\u6210\u529f&#xff01;&#xff01;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb835\u6b21\uff0c\u70b9\u8d5e9\u6b21\uff0c\u6536\u85cf16\u6b21\u3002\u624b\u52a8\u6267\u884c\u811a\u672c\u8fdb\u884c\u6d4b\u8bd5# \u67e5\u770b\u5907\u4efd# \u67e5\u770b\u6821\u9a8c\u7ed3\u679c\u6821\u9a8c\u7ed3\u679c\uff1a\u6d4b\u8bd5\u6210\u529f\uff01\uff01_openeuler\u914d\u7f6ersync<\/p>\n","protected":false},"author":2,"featured_media":24122,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[43,44,1851],"topic":[],"class_list":["post-24123","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-43","tag-44","tag-1851"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u5229\u7528rsync\u5907\u4efd\u5168\u7f51\u670d\u52a1\u5668\u6570\u636e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/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.wsisp.com\/helps\/24123.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u5229\u7528rsync\u5907\u4efd\u5168\u7f51\u670d\u52a1\u5668\u6570\u636e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb835\u6b21\uff0c\u70b9\u8d5e9\u6b21\uff0c\u6536\u85cf16\u6b21\u3002\u624b\u52a8\u6267\u884c\u811a\u672c\u8fdb\u884c\u6d4b\u8bd5# \u67e5\u770b\u5907\u4efd# \u67e5\u770b\u6821\u9a8c\u7ed3\u679c\u6821\u9a8c\u7ed3\u679c\uff1a\u6d4b\u8bd5\u6210\u529f\uff01\uff01_openeuler\u914d\u7f6ersync\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/24123.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-19T01:26:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419012635-6802fbcbd7308.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/24123.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/24123.html\",\"name\":\"\u5229\u7528rsync\u5907\u4efd\u5168\u7f51\u670d\u52a1\u5668\u6570\u636e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-19T01:26:37+00:00\",\"dateModified\":\"2025-04-19T01:26:37+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/24123.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/24123.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/24123.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u5229\u7528rsync\u5907\u4efd\u5168\u7f51\u670d\u52a1\u5668\u6570\u636e\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u5229\u7528rsync\u5907\u4efd\u5168\u7f51\u670d\u52a1\u5668\u6570\u636e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","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.wsisp.com\/helps\/24123.html","og_locale":"zh_CN","og_type":"article","og_title":"\u5229\u7528rsync\u5907\u4efd\u5168\u7f51\u670d\u52a1\u5668\u6570\u636e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb835\u6b21\uff0c\u70b9\u8d5e9\u6b21\uff0c\u6536\u85cf16\u6b21\u3002\u624b\u52a8\u6267\u884c\u811a\u672c\u8fdb\u884c\u6d4b\u8bd5# \u67e5\u770b\u5907\u4efd# \u67e5\u770b\u6821\u9a8c\u7ed3\u679c\u6821\u9a8c\u7ed3\u679c\uff1a\u6d4b\u8bd5\u6210\u529f\uff01\uff01_openeuler\u914d\u7f6ersync","og_url":"https:\/\/www.wsisp.com\/helps\/24123.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-19T01:26:37+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419012635-6802fbcbd7308.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/24123.html","url":"https:\/\/www.wsisp.com\/helps\/24123.html","name":"\u5229\u7528rsync\u5907\u4efd\u5168\u7f51\u670d\u52a1\u5668\u6570\u636e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-19T01:26:37+00:00","dateModified":"2025-04-19T01:26:37+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/24123.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/24123.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/24123.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u5229\u7528rsync\u5907\u4efd\u5168\u7f51\u670d\u52a1\u5668\u6570\u636e"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/24123","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=24123"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/24123\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/24122"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=24123"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=24123"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=24123"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=24123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}