digint / btrbk

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

Re-establish parent child relationship after btrbk restore #598

Open babyygemperor opened 2 months ago

babyygemperor commented 2 months ago

I recently lost my 16TB hard disk (/disk1) due to a mechanical failure. Thankfully I had a btrbk set up to create backups to my second disk (/disk2). This is how my btrbk.conf looks

transaction_log            /var/log/btrbk.log
snapshot_dir               snapshots
snapshot_preserve_min      24h
snapshot_preserve          7d 4w *m

target_preserve_min        24h
target_preserve            7d 4w *m

volume /disk1
    subvolume photos
        target send-receive /disk2/photos
    subvolume media
        target send-receive /disk2/media

In order to restore the backups, I copied everything using btrfs send /disk2/photos/photos.20240814 | btrfs receive /disk1 and then used btrfs subvolume snapshot /disk1/photos.20240814 /disk1/phtotos and then finally btrfs sub volume delete /disk1/photos.20240814 to restore my backups.

Everything was fine so far but I wanted my backups of (new) /disk1 to continue building on top of those already in /disk2.

Now the issue is that the new UUIDs of the subvolumes of /disk1 are not the matching the Parent UUID of the backups in /disk2, therefore my backups aren't incremental anymore. They are copied entirely separately.

I get the following warning in my btrbk: No common parent subvolume present, creating full backup...

Is there any way to somehow restore the parent child relationship for btrbk or my incremental backups to work again?

mipro98 commented 1 month ago

and then finally btrfs sub volume delete /disk1/photos.20240814

I think that was the mistake. If you read "Restoring Backups", it is advised to keep the copied subvolume until at least one new backup has been created:

Make sure to keep data.20150101 subvolumes on both disks at least until you created a new backup using btrbk, in order to keep the incremental chain alive.

This way, btrbk can detect a new common parent (the one you restored) on both the target and local disk and bases its incremental backup on this.