【发布时间】:2017-01-16 11:24:27
【问题描述】:
我正在尝试将“sdir”目录复制(rsync)到 tdir 目录,具体取决于日期。我想要一份完整的副本到 mon 目录,周二只有更改的内容,婚礼只有更改的内容,等等,但我没有得到我需要的结果。 参考我运行的实际命令:
[jesse@localhost test]$ tree
.
├── sdir
│ ├── file1
│ ├── file2
│ ├── file3
│ ├── file4
│ └── file5
└── tdir
├── fri
├── mon
│ ├── file1
│ └── file2
├── thu
├── tue
│ └── file3
└── wed
├── file3
├── file4
└── file5
7 directories, 11 files
[jesse@localhost test]$ touch sdir/file6
[jesse@localhost test]$ rsync -av --dry-run sdir/ --compare-dest=/home/jesse/test/tdir/mon/ /home/jesse/test/tdir/tue/ /home/jesse/test/tdir/wed/ /home/jesse/test/tdir//thu/ --backup-dir=/home/jesse/test/tdir/fri/
sending incremental file list
./
file3
file4
file5
file6
sent 294 bytes received 31 bytes 650.00 bytes/sec
total size is 0 speedup is 0.00 (DRY RUN)
[jesse@localhost test]$ rsync -av --dry-run sdir/ --compare-dest=/home/jesse/test/tdir/mon/ /home/jesse/test/tdir/tue/ /home/jesse/test/tdir/wed/ /home/jesse/test/tdir//thu/ --backup-dir=/home/jesse/test/tdir/thu/
sending incremental file list
./
file3
file4
file5
file6
sent 294 bytes received 31 bytes 650.00 bytes/sec
total size is 0 speedup is 0.00 (DRY RUN)
[jesse@localhost test]$ rsync -av --dry-run sdir/ --compare-dest=/home/jesse/test/tdir/mon/ /home/jesse/test/tdir/tue/ /home/jesse/test/tdir/wed/ --backup-dir=/home/jesse/test/tdir/thu/
sending incremental file list
./
file6
sent 208 bytes received 22 bytes 460.00 bytes/sec
total size is 0 speedup is 0.00 (DRY RUN)
[jesse@localhost test]$ rsync -av --dry-run sdir/ --compare-dest=/home/jesse/test/tdir/mon/ /home/jesse/test/tdir/tue/ /home/jesse/test/tdir/wed/ /home/jesse/test/tdir/thu/ --backup-dir=/home/jesse/test/tdir/thu/
sending incremental file list
./
file3
file4
file5
file6
sent 294 bytes received 31 bytes 650.00 bytes/sec
total size is 0 speedup is 0.00 (DRY RUN)
[jesse@localhost test]$ rsync -av sdir/ --compare-dest=/home/jesse/test/tdir/mon/ /home/jesse/test/tdir/tue/ /home/jesse/test/tdir/wed/ /home/jesse/test/tdir/thu/ --backup-dir=/home/jesse/test/tdir/thu/
sending incremental file list
./
file3
file4
file5
file6
sent 438 bytes received 95 bytes 1,066.00 bytes/sec
total size is 0 speedup is 0.00
[jesse@localhost test]$ tree
.
├── sdir
│ ├── file1
│ ├── file2
│ ├── file3
│ ├── file4
│ ├── file5
│ └── file6
└── tdir
├── fri
├── mon
│ ├── file1
│ └── file2
├── thu
│ ├── file3
│ ├── file4
│ ├── file5
│ └── file6
├── tue
│ └── file3
└── wed
├── file3
├── file4
└── file5
7 directories, 16 files
[jesse@localhost test]$
【问题讨论】:
-
您确定
--backup-dir是您想要的方式吗?我更相信--link-dest,因此每个备份都是完全可用的,相同的文件与之前的备份硬链接。也就是说,使用--itemize-changes(-i) 选项探索您所看到的内容。如果这确实是问题所在,可能会帮助您了解导致比较失败的原因。 -
你为什么要问 --backup-dir 是否可行?是不是很糟糕...在使用 --dry-run 而没有 --dry-run 时,我确实看到备份开关的结果不一致。使用 --dry-run,它会为我提供要更新的正确文件,但如果没有 --dry-run,它将复制自原始备份以来更改的所有内容。
-
当我运行
rsync source mon命令时,rsync 工作正常。它也适用于rsync source mon tue,但不是当我运行rsync source --compare-dest=mon tue wed时,这会中断并给我自周一以来发生的所有变化,并进入周三。使用--backup-dir似乎给了我正确的结果--dry-run但是当我在没有它的情况下运行它时,它会做同样的事情。