You are not logged in.

#1 2024-09-03 18:14:26

gabx
Member
From: Geneva, Switzerland
Registered: 2011-11-20
Posts: 245
Website

[SOLVED] snapshot of @home btrfs subvolume

I want to set a backup mechanism with btrfs subvolumes.
I am going step by step as not everything is clear to me about btrfs files system.
Below is part of my current set up:

$ cat /etc/fstab
/dev/nvme0n1p2 LABEL=Magnolia
UUID=6ca0f63e-7327-444e-af89-ac82d08fda59	/home     	btrfs     	rw,noatime,ssd,discard,space_cache=v2,subvol=/@home	0 0
/dev/sda1 LABEL=backup
UUID=dccf798a-53a3-4fe5-aa77-95dc0fd28458	/backup	btrfs     	rw,noatime,ssd,discard,space_cache=v2	0 0
------------------
# btrfs subvolume list /
ID 256 gen 61962 top level 5 path @
ID 257 gen 61962 top level 5 path @home
------------------------------------
$ lsblk
├─sda1      btrfs    400G     0% /backup    backup   dccf798a-53a3-4fe5-aa77-95dc0fd28458

Now I try this command:

# cd /
# btrfs subvolume snapshot @home /backup/snap_test
[sudo] password for gabx: 
ERROR: Could not statfs: No such file or directory

What ma I doing wrong when running this command?

Last edited by gabx (2024-09-05 10:56:53)

Offline

#2 2024-09-03 18:32:40

ua4000
Member
Registered: 2015-10-14
Posts: 558

Re: [SOLVED] snapshot of @home btrfs subvolume

from the manpage

btrfs subvolume is used to create/delete/list/show btrfs subvolumes and snapshots.
A BTRFS subvolume is a part of filesystem with its own independent file/directory hierarchy and inode number namespace.

Your /backup is ***not*** part of the filesystem, it's "another" filesystem.

Offline

#3 2024-09-03 20:20:42

gabx
Member
From: Geneva, Switzerland
Registered: 2011-11-20
Posts: 245
Website

Re: [SOLVED] snapshot of @home btrfs subvolume

I understand this. So what am I supposed to do?

Offline

#4 2024-09-03 20:42:06

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 13,528
Website

Re: [SOLVED] snapshot of @home btrfs subvolume


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#5 2024-09-03 21:19:30

gabx
Member
From: Geneva, Switzerland
Registered: 2011-11-20
Posts: 245
Website

Re: [SOLVED] snapshot of @home btrfs subvolume

So, I need to send the @home subvolume to the destination folder, /backup and not to run the snapshot commad? something like:

# btrfs send @home | btrfs receive /backup

Or shall I create a @backup subvolume and make it belong to the same group than the @home subvolume and in this case use the snapshot command?
The idea is to back up on another drive, in my case an external one (/backup is a partition of an external SSD)

Last edited by gabx (2024-09-03 21:22:20)

Offline

#6 2024-09-03 23:33:27

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 13,528
Website

Re: [SOLVED] snapshot of @home btrfs subvolume

I'm not well versed on the specifics, but the wiki page says that the snapshot being sent _must_ be read-only, so it's likely that you'll need to create a read-only snapshot first, then 'send' that, rather than sending the '@home' subvol directly.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#7 2024-09-04 14:46:31

ua4000
Member
Registered: 2015-10-14
Posts: 558

Re: [SOLVED] snapshot of @home btrfs subvolume

I also don't use the send/receive, nor read much about it from other users.
Maybe it's not widely used ?

If you search for a well tested, robust backup/snapshot solution, which has for sure many users, I recommend
https://wiki.archlinux.org/title/Rsync#Snapshot_backup
which is based on file-system hardlinks.

Offline

#8 2024-09-04 20:06:17

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: [SOLVED] snapshot of @home btrfs subvolume

gabx wrote:

I want to set a backup mechanism with btrfs subvolumes

A snapshot is not a backup. If the filesystem is corrupted then the snapshots will also be lost.

gabx wrote:

What ma I doing wrong when running this command?

The @home subvolume is mounted under /home/ so you should use the mountpoint instead of the subvolume name.


Jin, Jîyan, Azadî

Offline

#9 2024-09-05 07:32:45

gabx
Member
From: Geneva, Switzerland
Registered: 2011-11-20
Posts: 245
Website

Re: [SOLVED] snapshot of @home btrfs subvolume

Head_on_a_Stick wrote:

The @home subvolume is mounted under /home/ so you should use the mountpoint instead of the subvolume name.

running the following command leaves me with an error:

# btrfs subvolume snapshot /home /backup/snap_test 
ERROR: cannot snapshot '/home': Invalid cross-device link

It looks like there is an issue as /home and /backup/snap_test are not on the same device. I guess I must mix the snapshot with the send command.

Offline

#10 2024-09-05 09:05:58

willemw
Member
Registered: 2013-02-19
Posts: 116

Re: [SOLVED] snapshot of @home btrfs subvolume

[deleted]

Last edited by willemw (2024-09-05 09:20:18)

Offline

#11 2024-09-05 10:56:32

gabx
Member
From: Geneva, Switzerland
Registered: 2011-11-20
Posts: 245
Website

Re: [SOLVED] snapshot of @home btrfs subvolume

the snapshot creation works if both source and destination folders are on the same BTRFS device.

# btrfs subvolume snapshot /home /home/home_snapshot_$(date +%Y%m%d) 
Create snapshot of '/home' in '/home/home_snapshot_20240905'
$ ls -al /home
....
drwxr-xr-x 1 root root   24 Jul 10 16:44 home_snapshot_20240905/

Thereafter I can send the snapshot to an external drive.

Offline

Board footer

Powered by FluxBB