restic / restic

Fast, secure, efficient backup program

Home Page:https://restic.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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).

commented

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.

commented

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 ;)

commented

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 :)

commented

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.

Ah, I've mixed up the issues. This issue (#18) is about deleting a specific snapshot, whereas #51 is about such a prune command.

For this issue, just the user facing code is still missing (and maybe a few optimizations to the optimize code).

commented

Great! When you talk about optimizations to "optimize", do you mean to make it faster, or to make it just work?

commented

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.

commented

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.