簡體   English   中英

是否可以只使用lsyncd同步一個文件?

[英]Is it possible to sync just ONE file with lsyncd?

我真的很難過 - 我花了將近兩個小時的時間來尋找一個簡單易懂的問題的答案:我如何在Mac上不斷保持兩個本地文件的同步? 我研究了涉及rsync各種技巧,然后決定使用lsyncd

但對於我的生活,我無法弄清楚如何讓lsyncd同步兩個特定的文件。 API甚至支持這個嗎? 文檔中不清楚我是否可以這種方式使用rsync ; 我假設lsyncd正在傳遞阻止這種情況的CLI選項。 我的配置如下:

sync = {
    default.rsync,
    source = "/Users/username/Downloads/test1.txt",
    target = "/Users/username/Downloads/test2.txt",
    rsync = {
        binary = "/usr/local/bin/rsync",
        archive = "true"
    }
}

它只是說“無需同步”。 救命?

在lsynd你可以這樣做

settings {
    logfile = "/var/log/lsyncd.log",
    statusFile = "/var/log/lsyncd-status.log",
    statusInterval = 20,
    nodaemon = true
}
sync {
   default.rsync,
   source="/srcdir/",
   target="/dstdir/",
   rsync = {
     archive = true,
     compress = true,
     whole_file = false,
     _extra = { "--include=asterisk", "--exclude=*" },
     verbose = true
   },
   delay=5,
   log=all,
}

啟動后lsyncd我有下一個

root@localhost:/srcdir# ls
12  aster  asterisk

root@localhost:/dstdir# ls
asterisk

這對我有用:

sync {
    default.rsync,
    source = "/Users/username/Downloads/",
    target = "/Users/username/Downloads/",
    rsync = {
      binary = "/usr/bin/rsync",
      archive = "true",
      _extra = {
        "--include=test1.txt",
        "--exclude=*"
      }
    }
}

您必須使用lsyncd的包含/排除功能,它不是開箱即用的。 您必須使用_extra字段來設置它們。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM