Delete Specific Snapshot
scoddy opened this issue · comments
Function to delete Snapshots + related data (that is not needed by any other snapshot)
For safety, I think this is best implemented as a copying garbage collector, using hard links instead of actual copies. A fsck verifies the new "copy" before removing the old repo.
Interesting idea, but not portable. Local and sftp won't be the only backends, and hardlink-functionality may not always be available. But I'll think about it.
My fears of data loss may be too extreme, an in place garbage collector would work fine with an appropriate lock preventing new snapshots while collection is in progress.
The lock function is planned for exactly this (tracked in #91).
It would be great if there were an option to show how much space a snapshot deletion would free, without actually deleting.
That's not so easy to compute, because all the blobs might be also used by other blobs. We'll implement a few statistics later on (e.g. how many additional bytes were stored). Getting the exact number you'd like to know is possible, but computationally expensive.
But it can be known by the indices alone, right? Isn't the operation similar to a simulated "delete+optimize", so most code paths can be reused?
Yes, eventually when we have the code for deletion ;)
Is anyone working in implementing this feature? Seeing the issue date from 2014 diminishes hope a lot.
Yep, I've already implemented most of the code that is needed for this feature, especially detecting and removing unneeded blobs (including repacking, if other blobs in the same pack are still needed). This is already done, so we'll only need a bit of UI code that detects to-be-deleted snapshots, removes them and afterwards calls the optimizer code which prunes old data.
Stay tuned :)
What would be "detect to-be-deleted snapshots"? I specifically thought of a command like "restic delete 583a1b9d0a2" (a snapshot).
That's only the most basic thing a user should be able to do. I'm planning to implement something along the lines of the Attic prune
command, where users can specify rules for automatic deletion of matching snapshots: https://attic-backup.org/usage.html#attic-prune
For a local or sftp repository, deleting the snapshot file below snapshots/
followed by a run of restic optimize
on the repo should already do what you'd like to do. It isn't just yet available as a convenient command within restic.
Great! When you talk about optimizations to "optimize", do you mean to make it faster, or to make it just work?
I just tried; optimize said "15 unused blobs found, repacking..." and worked. Then I checked, and there were 20 packs not referenced in any index. Maybe they come from previous 'restic backup', when there were bugs about this.
Yeah, that's what I'm talking about. The code already works, but needs to be integrated better with the checker. Running optimize
should also remove unneded packs.
obnam has a nice syntax to specify "what snapshots to keep": http://code.liw.fi/obnam/manual/manual.html#removing-old-generations
That's nice for crontab calls to restic.
This is implemented and was merged just now, see https://restic.readthedocs.io/en/latest/Manual/#remove-a-single-snapshot