rsync打補丁以檢測檔案改名

2021-08-29 20:33:53 字數 2803 閱讀 1363

ubuntu中預設安裝的rsync是在同步檔案的時候,當檔案發生刪除、修改、建立的時候,都可以偵測到。但是當同步原始檔改名時,rsync同步到目標檔案時不是簡單的改名,而是會先刪除原有檔案然後再重新傳輸檔案過去,當檔案很大的時候,這種方案會比較耗時。如果rsync能夠自動偵測到原檔案改名並自動將目標檔案改名,則這個過程就會是瞬間完成。

$ patch -p1 然後再執行:

$ patch -p1 然後再執行下列命令:

$ sudo ./configure

$ sudo make

$ sudo make install

然後再檢視rsync版本是否變成3.1.3:

root@server-1:~/rsync-3.1.3# rsync --version

rsync version 3.1.3 protocol version 31

web site:

capabilities:

64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,

socketpairs, hardlinks, symlinks, ipv6, batchfiles, inplace,

rsync comes with absolutely no warranty. this is free software, and you

are welcome to redistribute it under certain conditions. see the gnu

general public licence for details.

說明rsync打補丁並安裝成功。

檢視rsync的--detect-renamed引數:

-y, --fuzzy                 find similar file for basis if no dest file

--detect-renamed try to find renamed files to speed up the transfer

--detect-renamed-lax ... and assume identical to source files (risky!)

--detect-moved ... only if basenames match (less risky)

這裡說了這個引數能夠讓rsync在檢測到檔案改名以後加速傳輸過程。

同步命令加上--detect-renamed引數。

src=/var/log/nginx

[email protected]::ftp

/usr/bin/inotifywait -mrq --timefmt '%d/%m/%y %h:%m' --format '%t %w%f%e' -e modify,create,delete,attrib $src | while read files

do rsync -vzrtopg --delete-delay --progress --exclude "*.gz" --password-file=/etc/rsync.pass $src $dst --detect-renamed

done

exit 0

現在測試檔案改名。將源資料夾中的檔案改名:

ubuntu@ip-172-31-26-91:/var/log/nginx$ ls

access.log access.log.12.gz access.log.2.gz access.log.4.gz access.log.7.gz error.log error.log.2.gz error.log.5.gz error.log.8.gz

access.log.10.gz access.log.13.gz access.log.3.gz access.log.5.gz access.log.8.gz error.log.1 error.log.3.gz error.log.6.gz error.log.9.gz

access.log.11.gz access.log.14.gz access.log.4 access.log.6.gz access.log.9.gz error.log.10.gz error.log.4.gz error.log.7.gz

ubuntu@ip-172-31-26-91:/var/log/nginx$ sudo mv access.log.4 access.log.5

inofify監聽到的事件:

sent 215 bytes  received 19 bytes  156.00 bytes/sec

total size is 9,637,614 speedup is 41,186.38

building file list ...

5 files to consider

nginx/

nginx/access.log

284,503 100% 90.22mb/s 0:00:00 (xfr#1, to-chk=3/5)

nginx/access.log.5

9,353,941 100% 46.70mb/s 0:00:00 (xfr#2, to-chk=2/5)

deleting nginx/access.log.4

正常的傳輸過程就200多k每秒,這裡的傳輸速度達到了46m/s,是因為rsync偵測到改名以後加速了傳輸過程。

記得打補丁

之前遇到個很怪的問題 買了個新硬碟,160g,重新裝了vs.net 2003,誰知道安裝後 安裝過程完全順利 在新建web專案時,出現如下資訊提示框,為什麼呢?於是便開始排除法解決。系統是win2000 sp4的,已經打了windows的補丁,硬碟c是fat32的。於是將.net framework...

OBIEE打補丁教程

要點 2 補丁解壓要徹底,直到出現etc files資料夾。昨天在使用obiee開發報表時遇到bug,決定給它打個補丁。二 配置環境 打補丁要先配置想要的opatch環境 在path環境變數中新增opatch目錄 f obi oracle bi1 opatch 或直接使用listary搜尋obiee...

Linux下打補丁

把改好的u boot 2010.09複製到資料夾patch,將u boot 2010.09重新命名為u boot 2010.09 fl2440 進入u boot 2010.09 fl2440,先make distclean 將原始碼包解壓到patch資料夾下 在此路徑下 diff nuar u bo...