如何rsync到不同的目录?

如何rsync到不同的目录?

这是我想要实现的目标:

运行 Rsync 以递归方式比较两个目录,如下所示:

rsync -r /source /target

但实际上并不在目录之间进行 rsync。我希望将产生的差异 rsyncd/复制到另一个 3. 目录。

有任何想法吗?

答案1

--compare-dest你的朋友在这里吗:

rsync -rvn --compare-dest /target/ /source/ /extra_target/

(确认适用后删除-v和-n)

这是一个显示它的 shell 会话:

dennis@lightning:~$ cd /tmp
dennis@lightning:/tmp$ mkdir rs1
dennis@lightning:/tmp$ touch rs1/f1
dennis@lightning:/tmp$ rsync -av rs1/ rs2/
sending incremental file list
created directory rs2
./
f1

sent 96 bytes  received 34 bytes  260.00 bytes/sec
total size is 0  speedup is 0.00
dennis@lightning:/tmp$ touch rs1/f2
dennis@lightning:/tmp$ rsync -avn rs1/ rs2/
sending incremental file list
./
f2

sent 71 bytes  received 18 bytes  178.00 bytes/sec
total size is 0  speedup is 0.00 (DRY RUN)
dennis@lightning:/tmp$ rsync -avn rs1/ rs3/
sending incremental file list
created directory rs3
./
f1
f2

sent 49 bytes  received 15 bytes  128.00 bytes/sec
total size is 0  speedup is 0.00 (DRY RUN)
dennis@lightning:/tmp$ rsync -rnv --compare-dest /tmp/rs2/ rs1/ rs3/
sending incremental file list
created directory rs3
f2

sent 49 bytes  received 15 bytes  128.00 bytes/sec
total size is 0  speedup is 0.00 (DRY RUN)

相关内容