digint / btrbk

Tool for creating snapshots and remote backups of btrfs subvolumes
https://digint.ch/btrbk/
GNU General Public License v3.0
1.69k stars 122 forks source link

Add the ability to prune old backups (where the source volume doesn't exist anymore) #237

Open mnowiasz opened 6 years ago

mnowiasz commented 6 years ago

Hi,

I've got the following use case:

Over the years I've backupped my old PC using btrfs ( 7d 4w 12m *y). I've replaced the PC with a laptop, moving most (but not all) data to the laptop which now creates the "new" backups.

Now, as the laptop creates it's backups I would like to prune the old PC laptops, retaining them according to the preserve policy, but I haven't found a way to do it - using a "dummy" volume will result in an error. So it would be quite useful to have the abilty of a "dummy/prune" volume which won't fetch anything but just prunes the old backups

mnowiasz commented 6 years ago

On second thought such a functionality wouldn't do a thing - because there are no new backups, therefore the old backups would be retained and no space would be gained.

What would do the trick: somehow defining that the "new" set of backups (in my example, the backups of my laptop) belongs (in respect of target_preserve) to an "old" set of backups (again, in my example the backups of my old PC), therefore a new backup (laptop) would result in deleting an old backup (depending on the preserve policy, of course)

digint commented 6 years ago

Have you tried using btrbk archive? You can specify archive_preserve rules which could probably be be used for pruning the backups.

mnowiasz commented 6 years ago

I'm not sure if archive would do the trick. I've got a set of PC backups:

[..] root.20180605 root.20180606 root.20180607 root.20180608 root.20180609 root.20180610 root.20180611 root.20180612

Then I've got a different set of Laptop backups:

root.20180611

Now what I would like to do: each time a new laptop backup is being created (say root.20180614), this backup would be taken into consideration into the preserve-police of the PC and the laptop, so in this case (7 days, 4 weeks..) PC's backups root.20180605-root.20180607 would be deleted. That makes sense because logically the laptop backup is a conituniation of the PCs one (although, of course, they share no common btrfs ancestor).

Could this be accomplished using btrbk archive?

digint commented 6 years ago

Hmm, probably not.

That makes sense because logically the laptop backup is a conituniation of the PCs one (although, of course, they share no common btrfs ancestor).

From my perspective it does not make much sense to store different sources to the same destination anyway, but maybe I'm missing a point here. How will you know which backup comes from which source? If they had a common btrfs ancestor (i.e. send/receive rootfs from PC to laptop), they would share most files and backup would profit from it, then it would make kind of sense to me.

mnowiasz commented 6 years ago

Well, the different source are stored in different directories - btrbk/seven/ for the old PC, btrbk/carrie for the laptop (and two other directories for servers). OK, one work around would be to move the backups from btrbk/seven/ to btrbk/carrie... after giving some thought that might be the best idea. Of course it would be hard to tell after a while if the backup came from seven or carrie, but on the other hand it's not important as long as the files are there.