使用unsion完成機器資料夾容災備份

2021-09-02 16:07:58 字數 1870 閱讀 1222

wget

tar -zvxf ocaml-4.03.0.tar.gz 

cd ocaml-4.03.0

./configure

make world opt

make install

tar -zxvf unison-2.48.4.tar.gz 

cd src

make uistyle=text

make install

mv: cannot stat '/root/bin//unison': no such file or directory

make: [doinstall] error 1 (ignored)

cp unison /root/bin/

cp: cannot create regular file '/root/bin/': is a directory

make: *** [doinstall] error 1

出現錯誤的原因在與unison預設是將檔案copy到/root/bin目錄,但linux預設是沒有該目錄的,因此我們需要將生成的可執行檔案unison複製到系統的path目錄。

[root@vm1 unison-2.40.63]# cp unison /usr/local/bin

vi /root/.unison/rsync.prf

寫入一下內容

root = /home/test1 

root = /home/test2

force= /home/test1

#ignore =

#batch = true

repeat = 1

#retry = 3

owner = true

group = true

perms = -1

fastcheck = false

rsync = false

sshargs = -c

xferbycopying = true

log = true

logfile = /root/.unison/unison.log

confirmbigdel=false

說明如下:

兩個root表示需要同步的資料夾

force表示以本地的/var/www/bbsnew資料夾為標準,將該目錄同步到遠端。注意,如果指定了force引數,那麼unison就變成了單項同步了,也就是說會以force指定的資料夾為準進行同步.

unison本身是可以雙向同步的,但是要做到雙向同步,就不要設定force引數,如果設定了force引數,就成了單項同步了,此時unison類似與sync.

unison雙向同步基本原理是:假如有a b兩個資料夾,a資料夾把自己的改動同步到b,b資料夾也把自己的改動同步到a,最後a b兩資料夾的內容相同,是 a b資料夾的合集.

unison雙向同步的乙個缺點是,對於乙個檔案在兩個同步資料夾中都被修改時,unison是不會去同步的,因為unison無法判斷以那個為準.

ignore = path表示忽略/sina/webdata下面的web-inf/tmp目錄,即同步時不同步它。

batch = true,表示全自動模式,接受預設動作,並執行

-fastcheck  true表示同步時使用檔案的建立時間來比較兩地檔案,如果這個選項為false,unison則將比較兩地檔案的內容.建議設定為true

log = true表示在終端輸出執行資訊。

logfile則指定了同時將輸出寫入log檔案。

unison rsync

檢視同步情況

後台執行

nohup unison rsync &

刪掉後台

ps -ef|grep unison

利用遞迴刪除資料夾(資料夾中套資料夾)

刪除目錄 bool deldir const ansistring p if p.isempty p.length 4 return false 引數必須大於3,即不能為磁碟根目錄或空白 int len p.length char path p.c str ansistring dir ansist...

在linux下修改資料夾機器子資料夾的許可權

使用命令 chmod 用法 chmod 選項 模式 模式 檔案.或 chmod 選項 八進位制模式 檔案.或 chmod 選項 reference 參考檔案 檔案.change the mode of each file to mode.with reference,change the mode ...

stp檔案怎麼變資料夾 打孔資料夾怎麼使用

打孔資料夾怎麼使用?廣州必能文具 必能文具來告訴大家 1 首先開啟打孔資料夾。2 然後取下資料夾圈口的壓條,並且掰開圈口。3 之後將打好孔的檔案安裝進去,切記孔的位置需要和圈口對應。4 最後再壓上壓條,就完成了。1 將需要整理的檔案疊放整齊,觀察打孔器,打孔器左邊為刻度標尺,有紙張尺寸標註,包括a4...