Recovering BTRFS snapshots

She’s going…

I hadn’t realised, the right pane had entered the folder, looked empty… so just went up one and deleted it.

So now I guess wait - it’s gonna slow down (42Mib/s now) and the progress is just counting up, eta didn’t work, but there’s no rush.

So next, can I just point timeshift at this folder later?

This was an emergency, so I did it by hand.
But usually it’s quite easy (for me) because I wrote a program for it. This saves ALL snapshots of a system to an external disk. The btrfs commands are generated automatically, and the btrfs option is also used to transfer the snapshot differentially.

You can take a look at it.

Yes, to my shame I have seen it… but I’m quite stupid and thought it complicated…

I also think on reinstalling I should use snapper.

That is beyond my knowledge. (I do not use Timeshift myself, because i think timeshift is not safe ( because it uses writeable snapshots))

I would do the same in reverse order:

  • btrfs send from your backup to a timeshift-snapshot (this will become a readonly one)
  • Then changing readonly → writeable.
1 Like

Ok, as a starting point I’ll try that.

At least now you have a complete backup (of one snapshot)

Backsnap would have done backups of all snapshots one after the other :wink:

If you have tips to make it more easy to use, you always can contact me.

And please continue to tell how it worked

(for the benefit of others)
(and for the benefit of backsnap)
:footprints:
P.S.:

Okay.

So it looks good so far, now I’m going to do the install - see you later :wink:

And… Thank you!

1 Like

Ok, fresh install. Opened Dolphin via Timeshift (ROOT) and F4 terminal, F3 dual pane and navigated to the snapshot sent out to the old Western Digital (W2) disk.

btrfs send --compressed-data /run/media/root/W2/SnapshotsBTRFS/@ | pv -pTteabfW -i 0.2 | btrfs receive /run/timeshift/24607/backup/RESTORE/
At subvol /run/media/root/W2/SnapshotsBTRFS/@

Seeing nice progress around 60~80MiB/s (though no eta… but knightrider style progress shuttle).

I’m stoked about sending snapshots out, my son @James2talk (now 12) just installed on his slimline laptop, so he’ll need to get a drive for external backups…

1 Like

You even can do this over ssh (with backsnap)
I do backup 5 PCs this way (1 local, 4 per ssh)
:footprints:

Now I sent @ from W2 into the timeshift folder:

/run/timeshift/34080/backup/timeshift-btrfs/snapshots

Now I see the folder of a fresh snapshot next to this @ snapshot.

However, Timeshift only sees the folder.

What’s the next step - to mount/restore this snapshot?
I see it listed:

[SteelLegend snapshots]# btrfs subvolume list /
ID 256 gen 169 top level 5 path @
ID 257 gen 169 top level 5 path @home
ID 258 gen 165 top level 5 path @cache
ID 259 gen 169 top level 5 path @log
ID 260 gen 72 top level 5 path @swap
ID 262 gen 95 top level 5 path timeshift-btrfs/snapshots/2024-01-21_00-23-05/@
ID 264 gen 160 top level 5 path timeshift-btrfs/snapshots/@

So I assume we won’t use Timeshift to restore it…

Now I’m in the Timeshift folder, and I made the @ read only.

So I’m guessing btrfs restore @/ but I can’t figure the <destination> 'cos it’s not simply / is it?

How i would solve it if it was snapper:

@ is your / subvolume
@home is your /home subvolume

From a live manjaro

With btrfs-root (not “@”, but “/” !) mounted to /mnt/BTRFSROOT
you see:

/mnt/BTRFSROOT/@ (damaged)
/mnt/BTRFSROOT/@home
/mnt/BTRFSROOT/@cache
/mnt/BTRFSROOT/@log
...
  • move /mnt/BTRFSROOT/@ to /mnt/BTRFSROOT/@damaged
  • make /mnt/BTRFSROOT/@damaged readonly
  • send @ from W2 to /mnt/BTRFSROOT/@
  • make /mnt/BTRFSROOT/@ writable

I think you are good to boot

if all goes well, in 10 days delete /mnt/BTRFSROOT/@damaged

step by step with explanations:

Haha ok, from a LIVE session.

Apart from being read-only, is there any other actual difference with the snapshots?

Once again, slightly confused - I see the snapshot on the mounted backup BTRFS volume:

btrfs send --compressed-data /mnt/W2/SnapshotsBTRFS/2/@ | pv -pTteabfW -i 0.2 | btrfs receive /run/media/manjaro/9e691e81-7bf8-42e2-a190-bf964d6f4549/snapshotsys
At subvol /mnt/W2/SnapshotsBTRFS/2/@
At subvol @

So my understanding is that now, the snapshot is on the new installed SSD at /snapshotsys/@

Rebooting from the SSD now:

btrfs subvolume list /                                                                                     
ID 256 gen 285 top level 5 path @
ID 257 gen 285 top level 5 path @home
ID 258 gen 271 top level 5 path @cache
ID 259 gen 285 top level 5 path @log
ID 260 gen 72 top level 5 path @swap
ID 262 gen 95 top level 5 path timeshift-btrfs/snapshots/2024-01-21_00-23-05/@
ID 264 gen 160 top level 5 path timeshift-btrfs/snapshots/@
ID 265 gen 254 top level 256 path snapshotsys/@

> btrfs subvolume get-default /   
ID 256 gen 284 top level 5 path @

This explanation is for your special use with custom layout of snapper.

I’m pretty sure this confuses a lot of newbies when using Btrfs with TimeShift or default layout of snapper.

I think so, any idea about how I could use that snapshot? I have just reinstalled again - and really want to restore that snapshot…

It felt so close.

Sorry, I haven’t read many posts here.

Which snapshot do you want to restore?

Sorry, hold on… I’ll need to come back again - I just reinstalled.

I’ve one snapshot which I exported to my external drive… which has now gone - so I’ll need to bring that in again.

The one I wanted was ID 265 gen 254 … snapshotsys/@

Okay, You want to reduce stress, reinstallation is an easier solution for newbies.

I’m not sure, I’m running into a lot of headaches with reinstalling - I forgot how much there is.

Stupid hiccups - like not now being able to get easystroke to build, and fzf not working right in Fish terminal after importing the configs…

Ok, so now starting again…

Step 1:

❯ btrfs send --compressed-data /mnt/W2/SnapshotsBTRFS/2/@ | pv -pteabfW -i 0.2 | btrfs receive /mnt/sys-back/

Send the @Snapshot from BTRFS W2 storage disk to /mnt/sys-back folder on the installed/running system.

So now I see:

btrfs subvolume show /mnt/sys-back/@/

@/mnt/sys-back/@

        Name:                   @
        UUID:                   d4cfc081-1a55-994a-997c-c7fea97205ef
        Parent UUID:            -
        Received UUID:          6c1c454b-2964-0543-bc47-87550424d1b8
        Creation time:          2024-01-21 15:16:13 +0700
        Subvolume ID:           264
        Generation:             222
        Gen at creation:        190
        Parent ID:              256
        Top level ID:           256
        Flags:                  readonly
        Send transid:           12457
        Send time:              2024-01-21 15:16:13 +0700
        Receive transid:        219
        Receive time:           2024-01-21 15:22:52 +0700
        Snapshot(s):
        Quota group:            n/a
btrfs subvolume show /
  Name:                   @
        UUID:                   241faeac-82ec-d243-ae23-0831657ecd49
        Parent UUID:            -
        Received UUID:          -
        Creation time:          2024-01-21 13:52:22 +0700
        Subvolume ID:           256
        Generation:             226
        Gen at creation:        10
        Parent ID:              5
        Top level ID:           5
        Flags:                  -
        Send transid:           0
        Send time:              2024-01-21 13:52:22 +0700
        Receive transid:        0
        Receive time:           -
        Snapshot(s):
                                timeshift-btrfs/snapshots/2024-01-21_14-00-05/@
                                timeshift-btrfs/snapshots/2024-01-21_15-00-02/@
                                timeshift-btrfs/snapshots/2024-01-21_15-20-33/@
        Quota group:            n/a

I wish to mount/restore the snapshot in sys-back…

ID 264 gen 222 top level 256 path mnt/sys-back/@

which also shows as ro=true.

# btrfs subvolume list /
ID 256 gen 230 top level 5 path @
ID 257 gen 230 top level 5 path @home
ID 258 gen 209 top level 5 path @cache
ID 259 gen 230 top level 5 path @log
ID 260 gen 53 top level 5 path @swap
ID 261 gen 35 top level 5 path timeshift-btrfs/snapshots/2024-01-21_14-00-05/@
ID 262 gen 158 top level 5 path timeshift-btrfs/snapshots/2024-01-21_15-00-02/@
ID 263 gen 160 top level 5 path timeshift-btrfs/snapshots/2024-01-21_15-00-02/@home
ID 264 gen 222 top level 256 path mnt/sys-back/@
ID 265 gen 207 top level 5 path timeshift-btrfs/snapshots/2024-01-21_15-20-33/@
ID 266 gen 209 top level 5 path timeshift-btrfs/snapshots/2024-01-21_15-20-33/@home
  1. Create a new Btrfs root directory /btrfs and mount it as a Btrfs root tree.
$ sudo mkdir /btrfs
$ sudo mount -t btrfs -o subvol=/ /dev/<Your disk> /btrfs/
  1. Check ls -al /btrfs to show all subvolumes within your system. If it works, then:

  2. Copy the sys-back/@ from the external disk back to your running system.

# mkdir /btrfs/sys_backup
# btrfs send /mnt/sys-back/@ | btrfs receive /btrfs/sys_backup/
  1. Recovery the backup
# mv /btrfs/@ /btrfs/@_backup
# mv /btrfs/sys_backup/@ /btrfs/
  1. Make the read-only subvolume writable.
# btrfs property set -ts /btrfs/@ ro false

Don’t forget to adjust UUID in your old fstab and /etc/default/grub after re-installation and recovery, then you need to rebuild initramfs (mkinitcpio -P) and update the bootloader of your choice (For example: update-grub for Grub)