page counter next up previous contents
Next: 用法五-排除特定檔案 Up: Rsync 檔案備援 Previous: 用法三-檔案新舊   Contents   DYWANG_HOME

用法四-刪除排外

  1. 在目端產生一個空檔 abc。
    [root@kvm5 ~]# touch /home/deyu1/cron.daily/abc
    
  2. 查看目的端目錄,多了一個檔案 abc。
    [root@kvm5 ~]# ll /home/deyu1/cron.daily/
    total 7
    -rwxr-xr-x. 1 root root 332 Mar 10  2015 0yum-daily.cron
    -rw-r--r--. 1 root root   0 Oct 11 16:27 abc
    -rwx------. 1 root root 191 Oct 11 16:15 logrotate
    -rwxr-xr-x. 1 root root 618 Mar 18  2014 man-db.cron
    [root@kvm5 ~]# rsync -auvh /etc/cron.daily /home/deyu1/
    sending incremental file list
    cron.daily/
    
    sent 124 bytes  received 16 bytes  280.00 bytes/sec
    total size is 1.13K  speedup is 8.07
    
  3. rsync 增加選項 -delete-excluded,同步後目的端多出來的檔案 abc 被刪除。
    [root@kvm5 ~]# rsync -auvh --delete-excluded /etc/cron.daily /home/deyu1/
    sending incremental file list
    deleting cron.daily/abc
    
    sent 121 bytes  received 13 bytes  268.00 bytes/sec
    total size is 1.13K  speedup is 8.43
    
  4. 查看目的端目錄檔案 abc 已被刪除。
    [root@kvm5 ~]# ll /home/deyu1/cron.daily/
    total 6
    -rwxr-xr-x. 1 root root 332 Mar 10  2015 0yum-daily.cron
    -rwx------. 1 root root 191 Oct 11 16:15 logrotate
    -rwxr-xr-x. 1 root root 618 Mar 18  2014 man-db.cron
    



De-Yu Wang 2020-05-14