【问题标题】:rsync files/folders from a list in an input file and exlude from an exclude file从输入文件中的列表中同步文件/文件夹并从排除文件中排除
【发布时间】:2019-04-15 04:29:24
【问题描述】:

我有两个带有文件夹列表的文件。我想将具有相对路径的文件夹同步到目标,不包括排除文件中的文件夹。

$ cat include.txt
/home/user
/etc
/data/app
/boot

$ cat exclude.txt
/data/app/temp
/etc/aide

我尝试过使用--include-from--files-from,但似乎无法弄清楚。

这似乎是同步文件夹,而不是文件:

rsync -av --files-from=include.txt / /destination

最终我想同步到/destination 并让文件夹结构看起来像:

/destination/home/user
/destination/home/user/...
/destination/etc
/destination/etc/...
/destination/data/app
/destination/data/app/...
/destination/boot
/destination/boot/...

【问题讨论】:

    标签: linux include rsync


    【解决方案1】:

    只需添加 -r--exclude-from 选项,您就可以开始了:

    rsync -av -r --files-from=./include.txt --exclude-from=./exclude.txt / /destination/
    

    【讨论】:

    • 我要打自己了。我怎么能错过--files-from 删除递归,所以你必须将它添加回来。我太笨了。谢谢!
    • 很高兴有帮助。这在 rsync 中是非常不直接的,我也在这个上打破了我的理论。
    猜你喜欢
    • 2016-06-17
    • 2012-11-30
    • 2013-05-17
    • 2020-05-05
    • 1970-01-01
    • 2014-07-23
    • 1970-01-01
    • 2012-02-12
    • 2013-12-23
    相关资源
    最近更新 更多