Unison 移动 root 与 rootalias

Unison move root with rootalias

我用我的副本从

更改了硬盘驱动器的安装点

/media/frisch/DATEN/Dok-Daniel/ISAS

/mnt/DATEN_SSD/ISAS

当我想同步这个时,Unison 说

Warning: No archive files were found for these roots, whose canonical names are: [...] Update detection may take a while on this run if the replicas are large.

我必须如何使用 rootalias 选项来使用旧存档文件(包含当前同步​​状态的内部 Unison 文件)而 Unison 不必重新读取我的所有文件?

rootalias 的正确语法是

rootalias = //new-hostname//new-path -> //old-hostname//old-path

(通过在命令提示符中键入 hostname 查找本地计算机的主机名。)

所以在我的例子中,两个驱动器都安装在本地计算机上,我必须像这样更改我的命令行:

旧:

unison -root "/media/frisch/DATEN_SSD/ISAS/" -root "/media/frisch/DATEN/Dok-Daniel/ISAS/"

新:

unison -root "/mnt/DATEN_SSD/ISAS" -root "/mnt/DATEN/Dok-Daniel/ISAS" \
-rootalias "//frisch-ThinkPad-P51//mnt/DATEN_SSD/ISAS -> \
//frisch-ThinkPad-P51//media/frisch/DATEN_SSD/ISAS" \
-rootalias "//frisch-ThinkPad-P51//mnt/DATEN/Dok-Daniel/ISAS -> \
//frisch-ThinkPad-P51//media/frisch/DATEN/Dok-Daniel/ISAS"

然后我可以在新位置同步文件,而无需缓慢的重新读取。

但是,请记住Unison作者的警告。

Warning: The rootalias option is dangerous and should only be used if you are sure you know what you're doing. In particular, it should only be used if you are positive that either (1) both the original root and the new alias refer to the same set of files, or (2) the files have been relocated so that the original name is now invalid and will never be used again. (If the original root and the alias refer to different sets of files, Unison's update detector could get confused.) After introducing a new rootalias, it is a good idea to run Unison a few times interactively (with the batch flag off, etc.) and carefully check that things look reasonable—in particular, that update detection is working as expected.

简短的修改,我在 DHCP 添加域时遇到了真正的问题,这就是 rootalias 不起作用的原因。

例如我试图添加 rootalias 指向同一台机器,但我找不到它不工作的原因。最后发现第一次同步是在其他网络位置完成的,其中路由器将 .lan 作为域,当前位置 DHCP 提供 .local 域. 因此,要发现旧的主机名,最好做

head -n3 ~/.unison/asddfrgrehrthtehrhtyrjyj

对于旧的同步数据库,检查当时的exact主机名,并执行此命令来识别当前主机名:

hostname
macbook.local

然后把它放到配置文件中,结果我有:

root = /my/Archiv
root = /Volumes/BACKUP/Archiv

rootalias = //macbook.local//my/Archiv -> //macbook.lan//my/Archive
rootalias = //macbook.local//Volumes/BACKUP/Archiv -> //macbook.lan//Volumes/BACKUP/Archive

旧位置是第二部分,在右边,这有效。