Restic stats vs. repository size

Hi,

I’m using restic for daily backups of my desktop machine to a remote sftp system for about a year now.

I noticed a difference between the restic stats (~31GB) output and the real repository size (~96 GB).

Does restic stats ignore some data? Or do I have stale data that’s not referenced by any snapshots?

restic@myhost:~$ restic prune
repository af8ef68a opened successfully, password is correct
loading indexes...
loading all snapshots...
finding data that is still in use for 22 snapshots
[0:39] 100.00%  22 / 22 snapshots
searching used packs...
collecting packs for deletion and repacking
[0:31] 100.00%  20476 / 20476 packs processed

to repack:            0 blobs / 0 B
this removes          0 blobs / 0 B
to delete:            0 blobs / 0 B
total prune:          0 blobs / 0 B
remaining:       983513 blobs / 95.921 GiB
unused size after prune: 4.784 GiB (4.99% of remaining size)

done

restic@myhost:~$ restic stats
repository af8ef68a opened successfully, password is correct
scanning...
Stats in restore-size mode:
Snapshots processed:   22
   Total File Count:   6745838
         Total Size:   30.711 GiB

restic@myhost:~$ ssh my-remote-host.com -l restic du -sh /backup/path
97G	.

What does restic stats --mode raw-data say?

restic@myhost:~$ restic stats --mode raw-data 
repository af8ef68a opened successfully, password is correct
scanning...
Stats in raw-data mode:
Snapshots processed:   22
   Total Blob Count:   960374
         Total Size:   89.826 GiB

Does this mean, I have 40 GB of blobs that a not referenced by any snapshot?

Nope, I think it means you’ve got 40 GiB worth of history. Stats gives you the restore-size. If you have files that change over time you will have different versions of them in the repository, but stats will count only one of them (the last one presumably). Raw mode will count all versions of the file.