| 作者 | fcamel (飛啊!起舞的小駱駝) | 看板 | P_fcamel |
| 標題 | Re: [FreeBSD] rsync, 同步更新不同機器的檔案 |
| 時間 | Fri Aug 13 13:44:06 2004 |
※ 引述《fcamel (飛啊!起舞的小駱駝)》之銘言:
> 自v2.6.0版開始, rsync預設使用ssh, 而非rsh, 不用擔心安全性
> ( 當然, 設好ssh key後, 使用rsync也不用打密碼 )
> 執行rsync的source/destination host都要安裝ssh和rsync
> 以我為例, 我想同步更新系上個人網站, 並且每天自動更新mirror site,
> 只要在mirror site (fcamel@fc.mjwu.net)下讓cron每天執行一次下面的指令即可
> /usr/local/bin/rsync -v -alp --delete \
> chlo@magpie.csie.nctu.edu.tw:~/public_html/web/ ~/public_html/web/
> -v: 顯示更新了那些檔案, 使用-v -v會連同skip那些檔案一並輸出
> man rsync會有詳細的說明
[NOTE] 在source尾端的"/", 會使執行結果不同
man rsync:
rsync -avz foo:src/bar /data/tmp
This would recursively transfer all files from the directory src/bar on
the machine foo into the /data/tmp/bar directory on the local machine.
The files are transferred in "archive" mode, which ensures that sym-
bolic links, devices, attributes, permissions, ownerships, etc. are
preserved in the transfer. Additionally, compression will be used to
reduce the size of data portions of the transfer.
rsync -avz foo:src/bar/ /data/tmp
A trailing slash on the source changes this behavior to avoid creating
an additional directory level at the destination. You can think of a
trailing / on a source as meaning "copy the contents of this directory"
as opposed to "copy the directory by name", but in both cases the
attributes of the containing directory are transferred to the contain-
ing directory on the destination. In other words, each of the follow-
ing commands copies the files in the same way, including their setting
of the attributes of /dest/foo:
rsync -avz /src/foo /dest
rsync -avz /src/foo/ /dest/foo
|