V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
请不要把任何和邀请码有关的内容发到 NAS 节点。

邀请码相关的内容请使用 /go/in 节点。

如果没有发送到 /go/in,那么会被移动到 /go/pointless 同时账号会被降权。如果持续触发这样的移动,会导致账号被禁用。
wniming
V2EX  ›  NAS

有没有这样一款能在 Linux 和 windows 之间同步文件夹的软件?

  •  1
     
  •   wniming · 31 天前 · 5121 次点击

    我需要将文件夹从 linux 同步到 windows ,windows 始终作为 linux 的一个镜像备份,这个需求本来只要是有有增量同步功能以及删除目标目录中存在但原目录中不存在的文件的功能的软件就行,但我会经常把一些大文件从 a 目录移动到 b 目录,我希望文件同步软件能做到在 windows 上也把这个文件从 a 目录移动到 b 目录,而不是把 a 目录下的这个文件删除掉,然后再重新把文件从 linux 的 b 目录拷贝到 windows 的 b 目录

    65 条回复    2025-03-02 13:07:48 +08:00
    terence4444
        1
    terence4444  
       31 天前
    Dropbox 可以做到,目前 Linux 下没有什么好用的 Onedrive 客户端
    nullico
        2
    nullico  
       31 天前   ❤️ 6
    syncthing 感觉可以啊
    nocmt
        3
    nocmt  
       31 天前
    微力同步,简单快捷
    zjsxwc
        4
    zjsxwc  
       31 天前 via Android   ❤️ 1
    传统的 rsync 不行吗,我觉得 rsync 不会傻到会把 move 同步成 delete&copy 。
    paperseller
        5
    paperseller  
       31 天前 via iPhone
    坚果云也行
    psllll
        6
    psllll  
       31 天前
    seafile
    wniming
        7
    wniming  
    OP
       31 天前 via Android
    @zjsxwc rsync 能在 windows 上作为系统服务运行吗?我想在 linux 上使用 rsync 协议进行同步
    wniming
        8
    wniming  
    OP
       31 天前
    @terence4444
    @nocmt
    @paperseller
    这种基于云盘的方案应该都是把文件上传到了云盘才能被云盘管理吧?这样的话不就太不方便了,我需同步的这个目录有很多几十个 G 的电影原片
    Jakarta
        9
    Jakarta  
       31 天前 via Android
    syncthing 可以
    wniming
        10
    wniming  
    OP
       31 天前   ❤️ 2
    @zjsxwc 刚才测试了一下两台 linux 机器用 rsync 同步目录,结果是 rsync 不会 move ,而是 delete&copy ,用的是下面的命令:

    rsync -av --delete test rsync://10.0.0.3/shm/test
    SenLief
        11
    SenLief  
       31 天前 via iPhone
    rsync -av --remove-source-files
    wniming
        12
    wniming  
    OP
       31 天前
    @SenLief 我运行

    rsync -av --remove-source-files test rsync://10.0.0.3/shm/test

    会把我源目录的文件都删除
    SenLief
        13
    SenLief  
       31 天前 via iPhone
    @wniming 没懂?你需要的不就是多端都移动目录吗?难道说想 linux 移动,win 不移动?
    wniming
        14
    wniming  
    OP
       31 天前
    @SenLief 我需求就是 linux 通过 mv 命令移动文件后,再通过某种软件把目录同步到 windows ,windows 当然也是要移动,但是我用 2 台 linux 测试

    rsync -av --remove-source-files test rsync://10.0.0.3/shm/test

    这条命令,结果就是执行完后执行这条命令的那台机的 test 目录下的所有文件都被删除了,我想要的效果是软件不会更改我源目录的文件,只会更改 10.0.0.3 这台目标机器上的目录
    Jacksu
        15
    Jacksu  
       31 天前   ❤️ 1
    要移动功能,只有 seafile/nextcloud 这种服务端软件(都有专门的数据库)可以做到,rsync 又不会在线监视你的文件变化,它只是每次发起同步的时候比对文件信息而已。
    flynaj
        16
    flynaj  
       31 天前 via Android
    syncthing 全平台同步软件,不过你需要的那个功能估计没有软件实现,特别是异构系统。
    BeautifulSoap
        17
    BeautifulSoap  
       31 天前 via Android
    ls 那么多推荐 syncthing 的 lz 就是不高兴试一下
    wniming
        18
    wniming  
    OP
       31 天前
    @BeautifulSoap 还在试。。。。
    hysjw
        19
    hysjw  
       31 天前
    只推荐 syncthing
    czhu
        20
    czhu  
       31 天前
    插个队 syncthing 和 resilio sync 怎么选?
    看了一圈 似乎 resilio rync 更成熟,pro 版本也免费了
    jokerhyc
        21
    jokerhyc  
       31 天前
    twig
        22
    twig  
       30 天前
    @Jakarta 哎呦,头像一定是你老婆。
    neutrino
        23
    neutrino  
       30 天前 via Android
    @terence4444 https://github.com/abraunegg/onedrive 这个蛮好用的,放 docker 里
    zjsxwc
        24
    zjsxwc  
       30 天前
    @wniming #10 试试: rsync -av --inplace --append test rsync://10.0.0.3/shm/test
    zjsxwc
        25
    zjsxwc  
       30 天前
    @zjsxwc #24 rsync -av --inplace --append --no-whole-file test rsync://10.0.0.3/shm/test
    w292614191
        26
    w292614191  
       30 天前
    nextCloud
    dufldylan1
        27
    dufldylan1  
       30 天前
    syncthing 用五年了,不只双端,支持多台设备组网,互相同步。掉线一个也不碍事
    MoeDisk
        28
    MoeDisk  
       30 天前
    自己写一个吧~
    lazyyz
        29
    lazyyz  
       30 天前
    一直用的 syncthing
    liyafe1997
        30
    liyafe1997  
       30 天前 via Android
    你要找的就是 syncting ,最无敌的去中心化&能穿透内网&开源跨平台的文件同步工具。
    用了好多好多年了,在 N 个设备上配置好后,简直就是个分布式网盘。
    xiaoz
        31
    xiaoz  
       30 天前
    Seafile ,全平台。
    bianjp
        32
    bianjp  
       30 天前
    syncthing 只适合两个设备同时在线的场景,感觉用处不大。
    比如办公电脑和家里的个人电脑,基本不会同时在线;笔记本安装的双系统也不会同时在线。
    swordsmile
        33
    swordsmile  
       30 天前
    可以试试 lsyncd 的 direct 模式,把 Windows 目录挂载过来。

    以下是 Debian 下的配置,仅供参考
    ```
    apt install lsyncd

    mkdir /etc/lsyncd/

    touch /var/log/lsyncd.log
    touch /var/log/lsyncd.status

    cat << 'EOF' > /etc/lsyncd/lsyncd.conf.lua
    settings {
    logfile = "/var/log/lsyncd.log",
    statusFile = "/var/log/lsyncd.status",
    insist = true,
    statusInterval = 10
    }

    sync {
    default.direct,
    source = "/tmp/src",
    target = "/tmp/dst",
    --delete = true,
    --delay = 60,
    maxProcesses = 1
    }
    EOF
    ```
    HrOice
        34
    HrOice  
       30 天前
    localsend 吧,多设备的
    chengzigua
        35
    chengzigua  
       30 天前
    我在 Windows 上有 git ,然后用 Git Bash 就可以运行 Linux 命令行了,再去搜一下“Windows Git Bash 里使用 rsync”之类的很多教程。我就是用这方法来同步云服务器上到本地电脑的非常好用,还能写 shell 脚本非常 nice 。
    mumuxiaoqiang
        36
    mumuxiaoqiang  
       30 天前
    scp
    Aalen
        37
    Aalen  
       30 天前
    搞个黑裙 用群辉的网盘同步
    ala2008
        38
    ala2008  
       30 天前
    syncthing 很强大,还开源
    hnliuzesen
        39
    hnliuzesen  
       30 天前
    Qsync 😅
    SenLief
        40
    SenLief  
       30 天前 via iPhone
    @wniming 我大概懂了,你想把操作也同步,这个 rsync 没办法,它只监控文件变化,如果想达到相同效果,需要两台机器都执行这个命令才行。
    noErr
        41
    noErr  
       30 天前
    WinSCP 啊
    polarwolf
        42
    polarwolf  
       30 天前
    free file sync 和 kopia 也可以看一下
    saranz
        43
    saranz  
       30 天前
    用 Wine 安装 oneDrive 感觉也是可以。
    1252603486
        44
    1252603486  
       30 天前
    syncthing 最好用
    jackey007
        45
    jackey007  
       30 天前
    不是很多人同时用的话,nextcloud 还是很稳定的
    kaizceo8
        46
    kaizceo8  
       30 天前
    windows 安装 minio linux 使用 mc
    linuxsir2020
        47
    linuxsir2020  
       30 天前
    歪个楼, 放在共享目录里操作 :)
    nativeBoy
        48
    nativeBoy  
       30 天前 via Android
    @bianjp 如果再搞个一直开机的设备会好点,比如 nas ,服务器,或者手机
    iamjs
        49
    iamjs  
       30 天前
    syncthing
    Jericho112
        50
    Jericho112  
       30 天前
    windows 开一个文件夹共享,打开编辑权限,局域网内 linux 连过去?
    wniming
        51
    wniming  
    OP
       30 天前
    测试了一下 syncthing ,基本满足需求,确实能在源目录(设置为仅发送的目录)的文件重命名或移动到其它目录时在目标目录(设置为仅接收的目录)上做同样的操作,唯一的问题是它基本上要求目标目录在第一次同步前是一个空目录,我测试过程中遇到两台机同步后状态都是“up to date”,但是目标目录中原来有的一些源目录中没有的文件没有被删除。

    syncthing 如果能让两个在第一次同步之前都非空的目录同步就好了,比如第一次同步之前先计算一下源目录和目标目录的所有文件的 md5 ,如果有 md5 相同的文件就不要从源目录拷贝,直接在目标目录移动或重命名,然后把存在在目标目录中但不存在在源目录中的文件删除掉,然后再把源目录中存在但目标目录中不存在的文件拷贝到目标目录,这样就能在目标目录已经有源目录的大部分文件,但是文件名和路径跟源目录不一样时发挥特别大的作用。
    wniming
        52
    wniming  
    OP
       30 天前
    @zjsxwc #24 #25 这两个都试了也是不行
    meeliao
        53
    meeliao  
       30 天前
    俺用的 syncthing ,体验还不错
    slrey
        54
    slrey  
       30 天前   ❤️ 1
    freefilesync 是这个功能的。

    它的官网是这么写的。

    Detect Moved Files
    FreeFileSync is able to detect moved files and quickly apply the same move on the target side during synchronization instead of a slow copy and delete. To makes this work, Use database file to detect changes must be checked and the file system must support file IDs.

    Note:
    Detection of moved files is not yet possible when synchronizing a folder pair for the first time. Only beginning with the second sync the database files are available to determine moved files.
    Detection is not supported on file systems that don't have (stable) file IDs. Most notably, certain file moves on FAT file systems cannot be detected. Also, protocols like SFTP do not support move detection. In these cases FreeFileSync will automatically fall back to "copy and delete".
    skiy
        55
    skiy  
       30 天前
    syncthing +1

    如果是单文件,就用 LocalSend
    joyxubing966
        56
    joyxubing966  
       30 天前
    @bianjp 卧槽 我一直以为是我使用问题
    xloong
        57
    xloong  
       30 天前
    @bianjp #32 可以手机也安装 syncthing, 充当中间传输的中转站, 我就这么干的
    而且手机相册直接设置同步到电脑, 当做备份, 去年 9 月份手机炸了, 基本不慌, 重要的文件电脑上都有备份

    @joyxubing966 #56
    stevenshum
        58
    stevenshum  
       29 天前
    Samba 呀,Samba 最大的功能就是可以用于 Linux 与 windows 系统直接的文件共享和打印共享。
    BKElectroCloud
        59
    BKElectroCloud  
       29 天前   ❤️ 1
    @czhu 一直在用 resilio rync ,近期根本打不了洞,没法提供广域网的文件同步了,唯一优势只剩下图形化多端操作简易了。
    louisyoungx
        60
    louisyoungx  
       29 天前
    这种场景真该买个 NAS 吧
    szguan
        61
    szguan  
       29 天前
    我用 freefilesync ,曾经特意观察了这个使用场景,如果 rename 文件夹名,它会 move ,而不是删除再新增。符合你的要求
    xyfan
        62
    xyfan  
       29 天前   ❤️ 1
    @wniming 你这个需求就不是正常场景下的同步需求,我觉得你应该自己写个脚本把目标文件夹调整到和源文件夹相同。就把你这段话送进 cursor ,需求描述的清楚,代码逻辑应该也不复杂。
    czhu
        63
    czhu  
       29 天前 via iPhone
    @BKElectroCloud 在用 syncthing 这个配置真是有点烦
    hanssx
        64
    hanssx  
       26 天前
    insync onedrive ,当然少量可以,大量不靠谱。
    hanssx
        65
    hanssx  
       26 天前
    我建议你直接 nas
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   921 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 21:25 · PVG 05:25 · LAX 14:25 · JFK 17:25
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.