gpt4 book ai didi

linux - 如何从两台服务器上都存在的 rsync 中排除目录?

转载 作者:太空狗 更新时间:2023-10-29 12:20:31 24 4
gpt4 key购买 nike

这是我的文件结构:

Server_A                  Server_B
============== ==============
/path/dir1/ /path/dir1/
logA.txt logA.txt
logB.txt logB.txt
/path/dir2/ /path/dir2/
fileC.txt fileC.txt
fileD.txt fileC.txt

我需要将 path/dir2 从服务器 A 同步到 B,但不是 path/dir1。

我的 rsync 命令如下所示:

rsync -arv --exclude '/dir1' /path/ root@server_b:/path

但每次我运行它时,结果都会在打印输出中显示 dir1:

sending incremental file list
./
dir1/
dir1/logA.txt
dir1/logB.txt
sent 52147 bytes received 23342 bytes 14405.50 bytes/sec
total size is 215619123 speedup is 2851.02

我错过了什么?

最佳答案

我不相信你已经准确地转录了你正在运行的命令。如果我有一个如下所示的目录 /tmp/src:

/tmp/src/
/tmp/src/dir1
/tmp/src/dir1/file1
/tmp/src/dir1/file2
/tmp/src/dir2
/tmp/src/dir2/file1
/tmp/src/dir2/file2

我可以将它同步到另一台服务器——并排除 /tmp/src/dir1——像这样:

rsync -av --exclude=/dir1 /tmp/src/ server:/tmp/dst/

运行看起来像这样:

sending incremental file list
created directory /tmp/dst
./
dir2/
dir2/file1
dir2/file2

这似乎与您在问题中描述的完全一致。我正在使用 rsync 版本 3.0.8。我建议仔细检查您的实际 rsync 命令行和文件系统。如果您没有看到任何明显的东西,您能否发布您正在运行的实际命令以及顶级目录列表(除非它很大)?

关于linux - 如何从两台服务器上都存在的 rsync 中排除目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10542073/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com