Prune when idle

I was thinking and doing some reading on the forums/GitHub: as far as I found, the reason that prune and forget are 2 different things is because prune is quite expensive and/or time consuming.

Because if this, would it maybe be a good feature to automatically prune the repository when no snapshots are being made and so the repository is idle? Could maybe be implemented in the Rest Server, to automatically prune the local repository or run a different process with restic that is able to watch the state of a repository?

I’m curious about what you guys would think and if that is even possible :).

Thanks!

I think this is currently not possible because:

  • prune requires an exclusive lock on the repository (no new backups in that time)
  • interrupting prune will leave the repository in an inconsistent state
  • it’s nearly impossbile to predict how long a prune run will take because that depends on the number of pack files which need to be rewritten

Thanks for your reply! I was indeed afraid for this. Would’ve been awesome, but as it isn’t possible to interrupt prune when a new backup comes in - it would be impossible to build this.

This is not true. Pruning can be safely interrupted without damage.

Well, you are technically correct. What I meant to say is that it will most probably throw some warnings at you when running check the next time.

I’m not sure this is true. The worst-case scenario is that you interrupt during pack rewrites. All you’d have in that situation are duplicate objects that aren’t in the index. Check doesn’t warn on this, AFAIK. A future prune will clean up the duplicates.