restic ls includes directories in the output, while I suspect that restic stats only counts files. (I don’t know if restic stats counts other nodes like symlinks. That could be another possible reason the counts might differ.)
Try running restic ls but excluding directories (and tail -n +2 to exclude the initial summary line):
Yeah, I considered that as well, but it doesn’t seem to be the case. I did some experiments on a very small repository (with 10 directories and 100 files), and I got exactly the same results from ls and stats - both files and directories were included the results from each command, and their outputs matched.
I also tested symlinks and hard links. No change.
On this repository, here are the results for ls without directories.
@David Sorry if this becomes me asking you to do some work, but I’m thinking “Can this be reproduced with a small repo?”. If one adds little data at a time, one should be able to spot when the two commands start producing different statistics.
Just trying to isolate it, and I’m thinking 1) it should be easier with a small test repo, and 2) while making a small test repo one should be able to spot it happening.
OK, if we’re thinking this is likely a bug, I’ll try to isolate. Instead of working to build up a small repo, I think it might be easier to pinpoint by instrumenting the code to determine which files exactly are being included in stats and ls as it examines the big repo.
I’ll give it a go and let you know what I come up with.