BTRFS / Schnapps: How big are my snapshots?

How can I find out, what space my snapshots take? It would be very convenient to be able to get this information.

1 Like

You may try the following approach:

  • Enable qgroups by
    btrfs quota enable /mnt/ssd

where /mnt/ssd is my mSata disk I used in TO. The help for the command suggests to turn on the quota on new disk but it seems it work even when enabling later

  • Run the following command
    btrfs qgroup show /mnt/ssd

each snapshot is actually a subvolume. The output of the command will show you:

  • qgroupid / subvolumeid
  • total size of the subvolume
  • size exclusively used by the subvolume - that should be the space you would get back if you delete this subvolume

It seems to work on the internal flash disk too. If you use the schnapps application then you need to map the ids. You can use
btrfs subvolume list /

and the last info should be the id presented via schnapps list

At least this is how I understand it :slight_smile:

Hopefully that helps.

Too complicated for my current skills. I have Turris with no additional ssd. Just the default memory and I’m too afraid to change your tutorial for main memory.

these are just commands

btrfs quota enable /
btrfs qgroup show /

and if this helps you I already did it on my TO. The result looks like:

qgroupid         rfer         excl
--------         ----         ----
0/5          20.00KiB     20.00KiB
0/258        97.22MiB     21.71MiB
0/262       826.68MiB    751.71MiB
0/266       612.14MiB    537.17MiB
0/268         1.30GiB      1.23GiB
0/274        36.00KiB     36.00KiB
0/276       171.16MiB      8.93MiB
0/288       896.14MiB     43.47MiB
0/290         1.14GiB     56.43MiB
0/293         1.31GiB     66.14MiB
0/294         1.31GiB     61.36MiB
0/295         1.31GiB     61.36MiB
0/296         1.31GiB     61.32MiB
0/297         1.31GiB     61.38MiB
0/298         1.31GiB     61.73MiB
0/300         1.83GiB      1.02GiB
0/302       161.21MiB    161.21MiB
0/303         9.30MiB      9.30MiB
0/304       302.88MiB     98.51MiB
0/306       302.84MiB     98.41MiB
0/307       271.24MiB     66.80MiB
0/308       171.14MiB      9.45MiB

If you do not use schnapps application then that’s it - you can see the subvolume / snapshot disk usage.

If you use schnapps then schnapps list can produce output like:

    # | Type      | Date                      | Description
------+-----------+---------------------------+---------------------------------
    7 | rollback  | 2016-10-29 18:51:31 +0000 | Rollback to snapshot factory
    9 | rollback  | 2016-10-29 19:16:43 +0000 | Rollback to snapshot factory
   13 | rollback  | 2016-11-04 07:07:04 +0000 | Rollback to snapshot factory
   24 | pre       | 2016-11-21 22:48:37 +0100 | Automatic pre-update snapshot
   26 | pre       | 2016-11-27 22:02:34 +0100 | Automatic pre-update snapshot
   28 | pre       | 2016-12-08 17:07:07 +0100 | Automatic pre-update snapshot
   29 | time      | 2016-12-11 01:05:01 +0100 | Snapshot created by cron
   30 | pre       | 2016-12-16 16:09:25 +0100 | Automatic pre-update snapshot
   31 | time      | 2016-12-18 01:05:02 +0100 | Snapshot created by cron
   32 | pre       | 2016-12-22 16:09:09 +0100 | Automatic pre-update snapshot
   33 | time      | 2016-12-25 01:05:01 +0100 | Snapshot created by cron
   34 | time      | 2017-01-01 01:05:02 +0100 | Snapshot created by cron
   35 | time      | 2017-01-08 01:05:02 +0100 | Snapshot created by cron

so if you want to map the outputs from these two command you need to run btrfs subvolume list / which gives you something like:

ID 258 gen 2933 top level 5 path @factory
ID 262 gen 41764 top level 5 path @7
ID 266 gen 41772 top level 5 path @9
ID 268 gen 41787 top level 5 path @13
ID 274 gen 43653 top level 5 path certbackup
ID 276 gen 43670 top level 5 path @
ID 288 gen 41810 top level 5 path @24
ID 290 gen 41841 top level 5 path @26
ID 293 gen 41904 top level 5 path @28
ID 294 gen 41941 top level 5 path @29
ID 295 gen 41941 top level 5 path @30
ID 296 gen 42008 top level 5 path @31
ID 297 gen 42031 top level 5 path @32
ID 298 gen 42072 top level 5 path @33
ID 300 gen 42075 top level 5 path @34
ID 302 gen 42531 top level 276 path srv/lxc/dbserver
ID 303 gen 42546 top level 276 path srv/lxc/dmznginx
ID 304 gen 42547 top level 276 path srv/lxc/webserver
ID 306 gen 42548 top level 276 path srv/lxc/webservertst
ID 307 gen 41543 top level 276 path srv/lxc/ws_bnextcloud
ID 308 gen 42076 top level 5 path @35

and you can use it as kind of mapping table - subvolume id 308 is id=35 in the schnapps output.

If you want to see the content of the snapshot you can use the schnapps application like schnapps mount 35 or you can use the mount command directly.

I wouldn’t be too afraid :slight_smile:

Cool. I’ll try to make script which would combine those two to show better human readable output. Thank you

So, I wrote small bash script to connect all parts together to show size of schnapps snapshots. I call it Schnappi. It’s far from perfect, I’m bash newbie, but it does what it should.

Download here: http://hawwwran.com/linux/tools/schnappi.sh

7 Likes

I made few changes, to make it responsive (frontend developer, you know). So now, if the size of terminal window is smaller than necessary, it changes design and tries to fit. If you want, you can use switch parameter to force view (-f for fullsize, -c for compact). And I removed seconds from date of creation.

enjoy.

works like a charm, thank you

Missing your File !
Link don’t work !
Thanks !

Try it again. The link works. Let me know.

Nope, got the following 404 message

Stránka nenalezena

Stránka, o kterou jste požádali, nebyla na serveru Hosting.BlueBoard.cz nalezena.

Pokud jste se přišli přes nějaký odkaz, napište nám na info (at) blueboard.cz, že je ten odkaz chybný.

That’ just absurd. This is the url I just tested and downloaded the file. Copy pase it or click it: http://hawwwran.com/linux/tools/schnappi.sh

Same 404 when I tried again.

i have checked it also and the link does work.

i have uploaded it to pastebin
http://pastebin.com/0p7ZX5jn

1 Like

It’s possible to retrieve the file without error if you don’t use ipv6, but I do have an ipv6 setup. hawwwran.com has a AAAA DNS record and on a network supporting ipv6 that DNS record will be used. It looks like the server setup for hawwwran.com doesn’t like requests coming in over ipv6 :slight_smile: I’m working with @hawwwran to figure it out.

1 Like

thanks for the update tonyquan, good luck with the resolution.

well done ubermutant !

@IWDickel et al, this file is now retrievable by those with ipv6 connections, @hawwwran resolved the issue with the hosting provider.

Unfortunately, running your .sh file with sh in turris terminal returns
schnappi.sh: line 27: syntax error: unexpected redirection
as of now

That seems to be problem with stty. It seems, that “stty size” command does not work for you.

*correction: It seems your shell does not have <<< redirection operator. It’s strange, because I use #!/bin/bash/

Do you run it like “./schnappi.sh”? Don’t run it like “sh ./schnappi.sh”, because that wouldn’t use bash.

1 Like