0

I have tried to get rsync --compare-dest to work as I expect, but I need some assistance. My goal is to create offline repo deltas for CentOS. I have one server connected to Internet where I store my CentOS mirror. I have a baseline for my offline system and I would like to create delta files because I need to carry the updates on optical discs.

I know that there is a lot of topics around the same issue, but I cannot get it to work.

This is an explanation how I have tried to get an easy example to work:

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

The files with the same name are copied, meaning exactly the same content. Now I have created a directory called diffresult/ where I would like to have the testfil3 copied.

If i diff the directories

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

Then I have tried a lot of different rsync compare-dest commands, for example:

[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 ~]$

So the issue seems to be that the files that are copied are the files that shows up I both directories not the Delta.

Is there a way to only copy the files that are the diff between the directories?

1 Answer 1

0

Is there a way to only copy the files that are the diff between the directories?

Yes. In your case all that's missing is that the comparison directory is relative to the destination. The same issue applies to link directories. The solution here is to use an absolute path

Scenario

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

Test run, copying files from testdiff1 to changed, but only those that are neither up-to-date in testdiff2 nor in changed

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

Output

sending incremental file list
./
testfil3

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

Evidence

ls changed/
testfil3

Note that if you copy between directories that look like they are on the local system, rsync will effectively degrade to making full copies (or none). If you run rsync across a network connection it can run an instance of itself at each end and you'll get the benefit of having only changes transferred.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .