Recovering BTRFS snapshots

Ok, once you’ve all stopped laughing - I borked my system… deleting what I thought was a mounted BTRFS snapshot, but actually recursively to the system until #$% h0… death.

Now in a live USB session, I can see my snapshots at


I also have a HDD with BTRFS and created a folder:


So my question is this: Can I just rsync that folder across and pick it up with Timeshift after installing?

How did you do you snapshots ?

  • rsync
  • btrfs

  • If you did the snapshots as btrfs snapshots, the best way to backup them is with btrfs send / btrfs receive !
  • if you did your snapshots with rsync (and you are really fit with rsync) then do your backup with rsync

With rsync it is really easy to:

  • miss some folders / files
  • trash the permissions

With btrfs send / receive this can not happen!

You allways have the complete snapshot with every file / folder and all the right file/folder parmissions. It is impossible to backup part of a snapshot :smiling_face_with_three_hearts:

BTRFS via Timeshift

OK, rsync finished - I’ll try to do BTRFS send now.

btrfs send 2024-01-20_18-00-02/ /run/media/manjaro/W2/SnapshotsBTRFS                                                                                                                  
ERROR: not dumping send stream into a terminal, redirect it into a file

Can I do this with the folder?

First you need to know your snapshots:

sudo btrfs subvolume show /
sudo btrfs subvolume show /
	Name: 			@
	UUID: 			82087774-426c-0847-99e8-bf3f364734e3
	Parent UUID: 		-
	Received UUID: 		-
	Creation time: 		2023-06-13 16:33:02 +0200
	Subvolume ID: 		256
	Generation: 		7674
	Gen at creation: 	10
	Parent ID: 		5
	Top level ID: 		5
	Flags: 			-
	Send transid: 		0
	Send time: 		2023-06-13 16:33:02 +0200
	Receive transid: 	0
	Receive time: 		-
	Quota group:		n/a
sudo btrfs subvolume show /home

Name: @home
UUID: e6c013df-62a8-c940-b18a-f7891f449168
Parent UUID: -
Received UUID: -
Creation time: 2023-06-13 16:33:02 +0200
Subvolume ID: 257
Generation: 7674
Gen at creation: 11
Parent ID: 5
Top level ID: 5
Flags: -
Send transid: 0
Send time: 2023-06-13 16:33:02 +0200
Receive transid: 0
Receive time: -
Quota group: n/a

I am running from live USB.

doas btrfs send 2024-01-20_18-00-02/ /run/media/manjaro/W2/SnapshotsBTRFS &> ~/Desktop/Send.txt

ERROR: failed to determine mount point for /run/media/manjaro/47d2594e-0752-4574-85a0-51b61b73acb4/timeshift-btrfs/snapshots/2024-01-20_18-00-02: Operation not permitted

sudo btrfs subvolume show /                                                                             ─╯
ERROR: Not a Btrfs filesystem: Invalid argument

Then you need to replace the path after show with the path you used to mount the volume or subvolume.

	Name: 			<FS_TREE>
	UUID: 			5e09c042-6d69-4546-8630-70f21f77c6ca
	Parent UUID: 		-
	Received UUID: 		-
	Creation time: 		2023-07-17 04:21:45 +0000
	Subvolume ID: 		5
	Generation: 		336313
	Gen at creation: 	0
	Parent ID: 		0
	Top level ID: 		0
	Flags: 			-
	Send transid: 		0
	Send time: 		2023-07-17 04:21:45 +0000
	Receive transid: 	0
	Receive time: 		-
	Quota group:		n/a

Lolz sorry - stress here.


1 Like

Don’t worry, we’ll get it done. :hammer_and_wrench:

With btrfs send / receive, the source-snapshot is never in danger .

Step 1:
We need to create a readonly snapshot (because Timeshift does create writable snapshots and btrfs send refuses to use them while they are writable).

To achieve this there are 2 ways:

  1. create a readonly snapshot from your writable one
  2. make the writable snapshot readonly by command

In your situation i would suggest way 1)

Are you familiar with creating snapshots by btrfs command ?

@home is empty, I have backups for that. I just want @

sudo btrfs subvolume show /run/media/manjaro/47d2594e-0752-4574-85a0-51b61b73acb4/timeshift-btrfs/snapshots/2024-01-20_18-00-02/@/                         

        Name:                   @
        UUID:                   6c1c454b-2964-0543-bc47-87550424d1b8
        Parent UUID:            ecda4cb9-17a9-6142-9f31-41940486c47d
        Received UUID:          -
        Creation time:          2024-01-20 11:00:05 +0000
        Subvolume ID:           5479
        Generation:             336330
        Gen at creation:        335064
        Parent ID:              5
        Top level ID:           5
        Flags:                  -
        Send transid:           0
        Send time:              2024-01-20 11:00:05 +0000
        Receive transid:        0
        Receive time:           -
        Quota group:            n/a

sudo btrfs send timeshift-btrfs/snapshots/2024-01-20_18-00-02/@ timeshift-btrfs/snapshots/2024-01-20_18-00-02/@ > ~/Desktop/btrfs-send.txt
ERROR: subvolume /run/media/manjaro/47d2594e-0752-4574-85a0-51b61b73acb4/timeshift-btrfs/snapshots/2024-01-20_18-00-02/@ is not read-only

As i said, there needs to be a readonly snapshot. (You cant send a snapshot while it would be possible to alter it)

sudo btrfs property get @ ro                                                                                      ─╯

Ok, how to change? Gimme a minute…

sudo btrfs property set @ ro true                                                                           
sudo btrfs property get @ ro                                                                            

Yay, this is better…

But now I tried:

sudo btrfs send @ /run/media/manjaro/W2/SnapshotsBTRFS > ~/Desktop/btrfs-send.txt                           ─╯
ERROR: all subvolumes must be from the same filesystem

I need to MOUNT it? maybe /mnt/snapshot/@ ?

Ok, now you can copy this snapshot to any other btrfs-partition (as root !) by:

btrfs send --compressed-data /tmp/BtrfsRoot/@snapshots/8310/snapshot | pv -pteabfW -i 0.2 | btrfs receive /tmp/BackupRoot/@BackSnap/server/8310

You need to

  • replace /tmp/BtrfsRoot/@snapshots/8310/snapshot with the name of your snapshot from show (yes it needs to be mounted somehow)
  • /tmp/BackupRoot/@BackSnap/server/8310 with the place to store it (This needs to be another btrfs-volume that is mounted somewhere)

Ok, I don’t have pv - installing that now.

pv can be omitted if you have no problem with btrfs not showing any progress and running forever.

Pv shows progress so you aren’t tempted to give up :wink:

Yes, it’s good.

sudo btrfs send --compressed-data @/ | pv -pTteabfW -i 0.2 | btrfs receive /run/media/manjaro/W2/SnapshotsBTRFS                                                       ─╯
At subvol @/
At subvol @
ERROR: chown  failed: Operation not permitted
1.64KiB {  0%} 0:00:00 [4.38MiB/s] [  <=>  

pv is nice, using fish I can see the options looking good… but now a chown fail.

We are getting close :smiling_face_with_three_hearts:
You cant do this with one sudo. You need one at the recieve also. (Because sudo only works up to the pipe)
Even better become root !

btrfs send --compressed-data @/ | pv -pTteabfW -i 0.2 | btrfs receive /run/media/manjaro/W2/SnapshotsBTRFS 
At subvol @/
At subvol @
ERROR: creating subvolume @ failed: File exists
 870  B {  0%} 0:00:00 [4.03MiB/s] [  <=> 

Take another name :wink: like /mnt/backupdisk/@_meineRettung

1 Like

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.