# Two root directories to sync. # You can use ssh:// to sync over SSH root = /home/alice/sync_folder root = ssh://dev@192.168.1.10//home/alice/sync_folder
# If you want one-way mirroring from one replica to the other, specify the source replica using "force" as follows. # force = /home/alice/sync_folder
# If you want Unison to run without any user input, try "batch" mode. batch = true
# If you don't want to be prompted, and just accept Unison's recommendation: auto = true
# Optionally, you can sync specific sub directories only (under the root). # path = dir1 # path = dir2
# Optionally, you can ignore specific files or directories that are matched with regular expressions. # ignore = Name *.o # ignore = Name *~ # ignore = Path */temp/archive_*
# If you want to ignore difference in file props: perms = 0
確定兩台主機都可以使用 SSH 連到對方,中間牽涉到一些問題,比如:
登入帳號是否具備有同步目錄以及子目錄的操作權限
若要排程同步就要注意帳號登入問題,最好是都將對方的 SSH public key 加到 authorize_keys,免密碼登入
執行雙向同步測試,檢查結果
unison sync
正常的結果如下:
Contacting server... Connected [//local//home/alice/sync_folder -> //remote_host//home/alice/sync_folder] Looking for changes Waiting for changes from server Reconciling changes new file --> document1.pdf <-- new file my.jpg Propagating updates UNISON 2.40.63 started propagating changes at 21:19:13.65 on 20 Sep 2013 [BGN] Copying document1.pdf from /home/alice/sync_folder to //remote_host//home/alice/sync_folder [BGN] Copying my.jpg from //remote_host//home/alice/sync_folder to /home/alice/sync_folder [END] Copying my.jpg [END] Copying document1.pdf UNISON 2.40.63 finished propagating changes at 21:19:13.68 on 20 Sep 2013 Saving synchronizer state Synchronization complete at 21:19:13 (2 items transferred, 0 skipped, 0 failed)