Kopia diff output

I created a script that shows the differences between two snapshots. I have this on a few other machines and the output is what I expected.

On one machine I see “sizes differ” and “modification times differ” for the directory and file before showing the actual file.

Differences...
. sizes differ:  14683062451 14719911459
. modification times differ:  2022-05-01 04:04:05.890767099 -0400 EDT 2022-05-02 04:11:25.749159909 -0400 EDT
./Administrative sizes differ:  223152366 264688601
./Administrative modification times differ:  2022-04-27 04:06:22.529734951 -0400 EDT 2022-05-02 04:11:24.145131802 -0400 EDT

How do I remove those “extra” lines containing “sizes differ” and “modification times differ” that show directory changes?

Code is here:

SPENT=`$KOPIA snapshot list -l | tail -1 | head -1 | cut -d\  -f6`
SLAST=`$KOPIA snapshot list -l | tail -2 | head -1 | cut -d\  -f6`

echo " "
echo "Differences..."
$KOPIA diff $SLAST $SPENT

I am using:

0.10.7 build: 5d87d817335f6d547e094ab80062113dc3a1fdf4 from: kopia/kopia

I think this question more suitable for stackoverflow

This should do what you want I guess

#!/bin/sh                                                                                                                                                                          
                                                                                                                                                                                   
kopia snapshot list -l | awk '{p=l; l=$4}                                                                                                                                          
END{                                                                                                                                                                               
  cmd = "kopia diff " p " " l                                                                                                                                                      
                                                                                                                                                                                   
  while( (cmd | getline) > 0) {                                                                                                                                                    
    if ( $0 !~ /^(removed|added|changed)/) continue;                                                                                                                               
    print;                                                                                                                                                                         
  }                                                                                                                                                                                
}                                                                                                                                                                                  
'

Well, I went with the simpler:

$KOPIA diff $SLAST $SPENT | grep -v "modification times differ" | grep -v "sizes differ"

I thought there was a flag that was set that was showing directory differences rather than just file differences.

If you wouldn’t ignore sizes differ then the first line produced by

kopia diff oldID newID |  head -n1

would give you total difference between two snapshots.

The same is true for directories difference, it shows side by side old and new size, so if you would parse kopia’s diff outcome for particular directories, you can filter out only size difference for those particular directories.