Recovering BTRFS snapshots

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)

ERROR: unable to resolve /mnt/sys-back/@
ERROR: realpath(/btrfs/@sys_backup) failed: No such file or directory…

So I’m just doing it /btrfs/@

/btrfs root@SteelLegend

❯ lsd -al
drwxr-xr-x root root  72 B Sun Jan 21 17:31:50 2024  .
drwxr-xr-x root root 272 B Sun Jan 21 18:42:17 2024  ..
drwxr-xr-x root root 272 B Sun Jan 21 18:42:17 2024  @
drwxr-xr-x root root 104 B Sat Jan 13 09:51:52 2024  @cache
drwxr-xr-x root root   6 B Sun Jan 21 17:22:37 2024  @home
drwxr-xr-x root root 210 B Sun Jan 21 18:29:28 2024  @log
drwxr-xr-x root root  16 B Sun Jan 21 17:22:07 2024  @swap
drwxr-xr-x root root 210 B Sun Jan 21 19:00:02 2024  timeshift-btrfs

But now I notice, you say to ‘recover the backup’ there should already be @, and the added @sysbackup - but there’s no @ in there…

So it’s impossible to mv/btrfs/@ /btrfs/@_backup

Does this mean the original ‘@’ is actually in root directory /?
Should I do

mv /@ /btrfs/@_backup
mv /btrfs/@ /@

When i look at the conversation in this Topic, i don’t understand why anyone would use BTRFS at all… i restored my EXT4 Partition on my PC and Laptop with Timeshift just for fun… and it was self explanation… how easy it was, to restore my stuff with the help from the Timeshift UI.

Booting into OS or Liveboot and starting timeshift, choosing the snapshot that i want to restore and clicking on the restore button and just follow the steps 1 by1, it was really user friendly.

1 Like

Oh, I see.

I fixed the part of my post:


Yes

That looks like you copied the system-subvolume @ from the external disk to the original @. This is bad.

You should separate two system-subvolumes @

1 Like

from an external backup?

Yeah, Timeshift with Btrfs is quite limited and inflexible.
Its alternative is btrfs-assistant with snapper as the dependency, but it is well suited for slightly advanced users who needs some abilities: Checksum and extremely fast creation of snapshots in less than 1 second in the running system.

1 Like