rsync --compare-dest, 결과가 가속화되지 않음

rsync --compare-dest, 결과가 가속화되지 않음

rsync --compare-dest예상대로 작동하도록 노력했지만 도움이 필요합니다. 내 목표는 CentOS용 오프라인 저장소 델타를 만드는 것입니다. CentOS 이미지를 저장하는 서버가 인터넷에 연결되어 있습니다. 오프라인 시스템에 대한 기준이 있고 업데이트를 디스크에 저장해야 하므로 델타 파일을 만들고 싶습니다.

동일한 문제에 대해 많은 주제가 있다는 것을 알고 있지만 작동시킬 수는 없습니다.

다음은 간단한 예제를 작동시키려고 시도한 방법에 대한 설명입니다.

[xttomfal@protectera-CentOS-Internet ~]$ ls testdiff1
testfil1  testfil2  testfil3
[xttomfal@protectera-CentOS-Internet ~]$ ls testdiff2
testfil1  testfil2

동일한 이름의 파일을 복사한다는 것은 내용이 완전히 동일하다는 것을 의미합니다. 이제 diffresult/testfil3을 복사하려는 디렉토리를 만들었습니다 .

디렉토리를 비교하면

[xttomfal@protectera-CentOS-Internet ~]$ diff testdiff1 testdiff2
Only in testdiff1: testfil3
[xttomfal@protectera-CentOS-Internet ~]$

그런 다음 다음과 같은 다양한 rsync Compare-dest 명령을 시도했습니다.

[xttomfal@protectera-CentOS-Internet ~]$ rsync -av --progress --stats --compare-dest=testdiff1 testdiff2/ diffresult/
sending incremental file list
--compare-dest arg does not exist: testdiff1
./
testfil1
              9 100%    0.00kB/s    0:00:00 (xfr#1, to-chk=1/3)
testfil2
              9 100%    8.79kB/s    0:00:00 (xfr#2, to-chk=0/3)

Number of files: 3 (reg: 2, dir: 1)
Number of created files: 2 (reg: 2)
Number of deleted files: 0
Number of regular files transferred: 2
Total file size: 18 bytes
Total transferred file size: 18 bytes
Literal data: 18 bytes
Matched data: 0 bytes
File list size: 0
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 215
Total bytes received: 106

sent 215 bytes  received 106 bytes  642.00 bytes/sec
total size is 18  speedup is 0.06
[xttomfal@protectera-CentOS-Internet ~]$ ls diffresult/
testfil1  testfil2
[xttomfal@protectera-CentOS-Internet ~]$

따라서 문제는 복사된 파일이 Delta 디렉터리의 파일이 아닌 두 디렉터리 모두에 파일로 표시되는 것 같습니다.

디렉터리 간에 diff 파일만 복사하는 방법이 있나요?

답변1

디렉터리 간에 diff 파일만 복사하는 방법이 있나요?

예. 귀하의 경우 누락된 점은 비교 디렉터리가 대상에 상대적이라는 것입니다. 연결된 디렉터리에도 동일한 문제가 적용됩니다. 여기서 해결책은 절대 경로를 사용하는 것입니다.

상상하다

mkdir /tmp/608927
cd /tmp/608927
mkdir testdiff{1,2} changed
touch testdiff1/testfil{1,2,3}
cp -p testdiff1/testfil{1,2} testdiff2/

테스트 실행, 에서 으로 파일을 복사 testdiff1하지만 최신 도 최신도 changed아닌 파일만 복사testdiff2changed

rsync -av --compare-dest "$PWD"/testdiff2/ testdiff1/ changed/

산출

sending incremental file list
./
testfil3

sent 165 bytes  received 38 bytes  406.00 bytes/sec
total size is 0  speedup is 0.00

증거

ls changed/
testfil3

로컬 시스템에 있는 것처럼 보이는 디렉터리 간에 복사하는 경우 rsync사실상 전체 복사본을 만들거나 복사본을 만들지 않는 것으로 다운그레이드됩니다. 네트워크 연결을 통해 실행 중인 경우 rsync각 끝에서 자체 인스턴스를 실행할 수 있으며 변경 사항만 전송하는 이점을 얻을 수 있습니다.

관련 정보