Skip to contentSkip to conversation

snapshots of subvolumes recursivly?

DISCUSSION Ulli Horlacher 2 participants 2 messages May 12, 2024 – May 13, 2024 Btrfs file system

lore
Share & tools
lore
#0 lore raw

I have asked a similar question 2019-07-05, but maybe meanwhile there is a solution...

I want to backup btrfs filesystems with IBM Spectrum Protect and restic, both are file based.

Copying files which are in write-open state will lead to file corruption. Therefore my idea is: create a snapshot and run the backup on the snapshot.

The problem now is: some of the btrfs filesystems have subvolumes and even sub-subvolumes.

When I create a snapshot it does not contain subvolumes. Example:

root@fex:/local/test# btrfs subvolume list .
ID 350 gen 6075947 top level 5 path home
ID 62530 gen 6075904 top level 5 path test
ID 62531 gen 6075894 top level 62530 path sv1
ID 62532 gen 6075895 top level 62530 path sv2
ID 62533 gen 6075894 top level 62531 path sv1/sv1_1
ID 62534 gen 6075894 top level 62531 path sv1/sv1_2
root@fex:/local/test# ll -R
drwxr-xr-x  root     root                       - 2024-05-12 20:42:02  sv1
drwxr-xr-x  root     root                       - 2024-05-12 20:42:10  sv1/sv1_1
-rw-r--r--  root     root                      20 2024-05-12 20:42:10  sv1/sv1_1/zz
drwxr-xr-x  root     root                       - 2024-05-12 20:42:17  sv1/sv1_2
-rw-r--r--  root     root                      20 2024-05-12 20:42:17  sv1/sv1_2/zz
-rw-r--r--  root     root                      20 2024-05-12 20:42:02  sv1/zz
drwxr-xr-x  root     root                       - 2024-05-12 20:42:25  sv2
-rw-r--r--  root     root                      20 2024-05-12 20:42:25  sv2/zz
-rw-r--r--  root     root                      20 2024-05-12 20:40:58  zz
root@fex:/local/test# btrfs sub snap . backup
Create a snapshot of '.' in './backup'
root@fex:/local/test# ll -R backup
drwxr-xr-x  root     root                       - 2024-05-12 20:40:58  backup
drwxr-xr-x  root     root                       - 2024-05-12 20:47:58  backup/sv1
drwxr-xr-x  root     root                       - 2024-05-12 20:47:58  backup/sv2
-rw-r--r--  root     root                      20 2024-05-12 20:40:58  backup/zz
root@fex:/local/test# btrfs subvolume list .
ID 350 gen 6075947 top level 5 path home
ID 62530 gen 6075904 top level 5 path test
ID 62531 gen 6075894 top level 62530 path sv1
ID 62532 gen 6075895 top level 62530 path sv2
ID 62533 gen 6075894 top level 62531 path sv1/sv1_1
ID 62534 gen 6075894 top level 62531 path sv1/sv1_2
ID 62535 gen 6075903 top level 62530 path backup

As you see: the snapshot /local/test/backup does not contain the sv* subvolumes, only empty directories backup/sv1 backup/sv2

I could write a script which creates snapshots of the subvolumes (recursivly), but maybe there is already such a program? Or another solution for this problem?

Signature · 6 lines
Ullrich Horlacher              Server und Virtualisierung
Rechenzentrum TIK
Universitaet Stuttgart         E-Mail: [email protected]
Allmandring 30a                Tel:    ++49-711-68565868
70569 Stuttgart (Germany)      WWW:    https://www.tik.uni-stuttgart.de/
REF:<[email protected]>
#1 lore raw
Quoted 8 lines · Ulli Horlacher

I have asked a similar question 2019-07-05, but maybe meanwhile there is a solution...

I want to backup btrfs filesystems with IBM Spectrum Protect and restic, both are file based.

Copying files which are in write-open state will lead to file corruption. Therefore my idea is: create a snapshot and run the backup on the snapshot.

You could use "btrfs send" to send whole snapshot instead of file.

Quoted 42 lines

The problem now is: some of the btrfs filesystems have subvolumes and even sub-subvolumes.

When I create a snapshot it does not contain subvolumes. Example:

root@fex:/local/test# btrfs subvolume list .
ID 350 gen 6075947 top level 5 path home
ID 62530 gen 6075904 top level 5 path test
ID 62531 gen 6075894 top level 62530 path sv1
ID 62532 gen 6075895 top level 62530 path sv2
ID 62533 gen 6075894 top level 62531 path sv1/sv1_1
ID 62534 gen 6075894 top level 62531 path sv1/sv1_2
root@fex:/local/test# ll -R
drwxr-xr-x  root     root                       - 2024-05-12 20:42:02  sv1
drwxr-xr-x  root     root                       - 2024-05-12 20:42:10  sv1/sv1_1
-rw-r--r--  root     root                      20 2024-05-12 20:42:10  sv1/sv1_1/zz
drwxr-xr-x  root     root                       - 2024-05-12 20:42:17  sv1/sv1_2
(quoted diff) +0 -2
-rw-r--r--  root     root                      20 2024-05-12 20:42:17  sv1/sv1_2/zz
-rw-r--r--  root     root                      20 2024-05-12 20:42:02  sv1/zz

drwxr-xr-x root root - 2024-05-12 20:42:25 sv2

(quoted diff) +0 -2
-rw-r--r--  root     root                      20 2024-05-12 20:42:25  sv2/zz
-rw-r--r--  root     root                      20 2024-05-12 20:40:58  zz
root@fex:/local/test# btrfs sub snap . backup
Create a snapshot of '.' in './backup'
root@fex:/local/test# ll -R backup
drwxr-xr-x  root     root                       - 2024-05-12 20:40:58  backup
drwxr-xr-x  root     root                       - 2024-05-12 20:47:58  backup/sv1
drwxr-xr-x  root     root                       - 2024-05-12 20:47:58  backup/sv2
-rw-r--r--  root     root                      20 2024-05-12 20:40:58  backup/zz
root@fex:/local/test# btrfs subvolume list .
ID 350 gen 6075947 top level 5 path home
ID 62530 gen 6075904 top level 5 path test
ID 62531 gen 6075894 top level 62530 path sv1
ID 62532 gen 6075895 top level 62530 path sv2
ID 62533 gen 6075894 top level 62531 path sv1/sv1_1
ID 62534 gen 6075894 top level 62531 path sv1/sv1_2
ID 62535 gen 6075903 top level 62530 path backup
Quoted 6 lines

As you see: the snapshot /local/test/backup does not contain the sv* subvolumes, only empty directories backup/sv1 backup/sv2

I could write a script which creates snapshots of the subvolumes (recursivly), but maybe there is already such a program? Or another solution for this problem?

From what I understand, subvolume created a way to split your "snapshot zone" for better data management(e.g. you can snapshot / without including /home or /var). This is intented.

So if you want to backup sv1 sv2, why you created subvolume in the first place?

HAN Yuwei