ngosang/restic-exporter

Duplicated snapshots because of paths

ferrarimarco opened this issue · 1 comments

Hi! Thanks for this exporter.

As explained in #8, restic-exporter calculates its own hash:

def calc_snapshot_hash(self, snapshot: dict) -> str:
text = snapshot["hostname"] + snapshot["username"] + ",".join(snapshot["paths"])
return hashlib.sha256(text.encode("utf-8")).hexdigest()

In my setup, using snapshot["paths"] as part of the input to calculate the hash causes a client to appear multiple times if the paths change, even if the rest (hostname and username) stays the same. For example, if you add or remove a path from the ones that restic is backing up for a given host and user, the exporter will report this as two different items.

I was surprised by this behavior because the metrics don't expose the paths for a given snapshot, IIRC.

Thanks for your support!

If you change the path it counts as a different backup, in Restic CLI and in the Exporter. Furthermore, some users have multiple backups per user and there hostname + username is not enough to distinguish backups.
You can remove the old backups (with different path) using the Restic CLI. They will be removed from the exporter too.

#11 (comment)