Is there a way to check for sizes of different contributions to a restic repo?

I have restic repo with backups from 3 different hard drives. I’m curious how big each one is in the repo vs on the actual file system as I do lots of hardlinking / retagging shenanigans, which I’m curious how effective restic de-duplication was at working around.

Restic stats command just shows how big the entire repo is, which is not helpful for this purpose.

Is there a way to do this?

You can use the --path flag to just print stats for a single path, which you could set to the mountpoint of your drive(s). Or if each drive is backed up in its own separate snapshot, appending the snapshot ID to the end of your stats command would work too.

Run restic stats --help for the full usage details. You might also want to change the mode, as it defaults to “restore-size”, which will just tell you how large your files would be once restored.

1 Like

How would you type out the full thing?

I tried: sudo restic -r /backups/restic-repo stats --path D:\Data --mode raw-data
which returns:

drambit@toaster:~$ sudo restic -r /backups/restic-repo stats --path D:\ --mode raw-data
enter password for repository:
repository 33e3844c opened (version 2, compression level auto)
Ignoring "raw-data": no matching ID found for prefix "raw-data"
Ignoring "filters": explicit snapshot ids are given

I also tried sudo restic -r /backups/restic-repo stats --path="D:\" --mode="raw-data"
Which results in:

repository 33e3844c opened (version 2, compression level auto)
Stats in restore-size mode:
     Snapshots processed:  0
              Total Size:  0 B

Ah, looks like typing it all in a different order fixed things. I tried: sudo restic stats -r "/backups/restic-repo" --path "D:\Data" --mode "raw-data"
that worked.

The results are pretty interesting, I don’t really know what to make of this

I have no idea how it managed to save this much data. Strangely, when I run the same command but on C:\Data (totally unrelated backup in the same repo) it gives me exactly the same results. Something is wrong here. Changing it to just "C:" gives 0 bytes again.

Are Windows drive letters not included like that in the paths?

Hmmm, I did a bit of testing on my side, and I think I may have been mistaken here, sorry about that.
It looks like --path is only used for filtering the snapshots to query with stats, rather than filtering the data from inside the snapshot to gather stats about:

--path path only consider snapshots including this (absolute) path (can be specified multiple times)

So even with --path, stats still returns the statistics for the entire snapshot, rather than the path you were filtering the snapshot list by.

The only way I can think to separate out the statistics per path, would be to backup only the path of interest. You’d then have a snapshot containing just that path, and could run stats against that snapshot, which would just be the stats of that single path.

Apart from that, it looks like you got the syntax correct; but I note that you didn’t specify a snapshot ID to the stats command. Because of this, restic provided combined stats for 2 snapshots for the stats run in your screenshot, which I guess both contain D:\Data.

Ah interesting, thank you for taking a look into this.

Do you know if it’s possible when you take snapshots to have them named something other than a random series of numbers?

I could easily run my snapshots separately, but it would be very tedious trying to keep track of which snapshot belongs to which directory.

Could you not just tag them differently?

In addition to the already mentioned tags, the snapshot will also show which directories were passed as backup arguments to it, and you can filter by those paths.
So if you backed up D:\Data in one snapshot and C:\Data in another, you should be able to filter/group snapshots by those paths for restic operations.

The above said, this is only a problem if you want to be able to review the per directory stats on a continual basis. If you just want to see them as a one off, you only need to back up each directory into separate snapshots once, and you can even restic forget those snapshots once done.