All of lore.kernel.org
 help / color / mirror / Atom feed
* what mens gen and ogen in btrfs sub list / ?
@ 2022-03-24 12:38 Lentes, Bernd
  2022-04-14 11:32 ` Andrew Skretvedt
  2022-04-14 13:39 ` Nikolay Borisov
  0 siblings, 2 replies; 3+ messages in thread
From: Lentes, Bernd @ 2022-03-24 12:38 UTC (permalink / raw)
  To: Btrfs ML

[-- Attachment #1: Type: text/plain, Size: 1825 bytes --]


Hi,

i'd like to write a script in which, beneath other stuff, the oldest snapshot(s) are deleted.
So i'm looking for a way to sort the list of the snapshots by date.
I read the manpage and stumbled across gen and ogen of snapshots.
But what does that mean and how can the values be interpreted ?
Or is there another way to list the snapshots by e.g. creation date ?

OS: Ubuntu 20.04
btrfs-progs: 5.4.1-2

root@nc-mcd:~/skripte# btrfs sub list -tcg /
ID      gen     cgen    top level       path
--      ---     ----    ---------       ----
273     1060462 170590  5               snapshots/pre_upgrade_27112020
279     1060464 1006204 5               snapshots/root-19102021


Thanks.

Bernd



--
Bernd Lentes 
System Administrator 
Institute for Metabolism and Cell Death (MCD) 
Building 25 - office 122 
HelmholtzZentrum München 
bernd.lentes@helmholtz-muenchen.de 
phone: +49 89 3187 1241 
fax: +49 89 3187 2294 
http://www.helmholtz-muenchen.de/mcd 


Public key: 

30 82 01 0a 02 82 01 01 00 b3 72 3e ce 2c 0a 6f 58 49 2c 92 23 c7 b9 c1 ff 6c 3a 53 be f7 9e e9 24 b7 49 fa 3c e8 de 28 85 2c d3 ed f7 70 03 3f 4d 82 fc cc 96 4f 18 27 1f df 25 b3 13 00 db 4b 1d ec 7f 1b cf f9 cd e8 5b 1f 11 b3 a7 48 f8 c8 37 ed 41 ff 18 9f d7 83 51 a9 bd 86 c2 32 b3 d6 2d 77 ff 32 83 92 67 9e ae ae 9c 99 ce 42 27 6f bf d8 c2 a1 54 fd 2b 6b 12 65 0e 8a 79 56 be 53 89 70 51 02 6a eb 76 b8 92 25 2d 88 aa 57 08 42 ef 57 fb fe 00 71 8e 90 ef b2 e3 22 f3 34 4f 7b f1 c4 b1 7c 2f 1d 6f bd c8 a6 a1 1f 25 f3 e4 4b 6a 23 d3 d2 fa 27 ae 97 80 a3 f0 5a c4 50 4a 45 e3 45 4d 82 9f 8b 87 90 d0 f9 92 2d a7 d2 67 53 e6 ae 1e 72 3e e9 e0 c9 d3 1c 23 e0 75 78 4a 45 60 94 f8 e3 03 0b 09 85 08 d0 6c f3 ff ce fa 50 25 d9 da 81 7b 2a dc 9e 28 8b 83 04 b4 0a 9f 37 b8 ac 58 f1 38 43 0e 72 af 02 03 01 00 01

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 2217 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: what mens gen and ogen in btrfs sub list / ?
  2022-03-24 12:38 what mens gen and ogen in btrfs sub list / ? Lentes, Bernd
@ 2022-04-14 11:32 ` Andrew Skretvedt
  2022-04-14 13:39 ` Nikolay Borisov
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Skretvedt @ 2022-04-14 11:32 UTC (permalink / raw)
  To: linux-btrfs

Hello, basic btrfs user and enthusiast here. I have a reaction, seeing
as none of the experts here have so far replied,

On 3/24/22 7:38 AM, Lentes, Bernd wrote:
> I read the manpage and stumbled across gen and ogen of snapshots.
> But what does that mean and how can the values be interpreted ?
> Or is there another way to list the snapshots by e.g. creation date ?

I'm going by the manpages,

I don't claim to understand the concept of "generation" with respect to
subvolumes, but I've noted that it seems to be something that
continually increases as you use a btrfs filesystem. In doing some tests
today, I find that when I create a new subvolume inside another, the gen
of the containing subvolume and the newly created subvolume increase to
a new, larger value in common to both, and that the cgen (someone can
say how cgen and ogen relate, the manpage doesn't mention cgen, while
the tools report it, and it seems like cgen is a new name for ogen) on
the newly created subvolume is the value the containing subvolume gen
had before the new subvolume was created.

So, these values don't seem to me to be what you'd want to track.

> i'd like to write a script in which, beneath other stuff, the oldest snapshot(s) are deleted.
> So i'm looking for a way to sort the list of the snapshots by date.

Here, the rootids are closer to what you want. These also increase with
each new subvolume created. Newer snapshots will have higher IDs than
older ones. Also the 'btrfs subvolume list' command has an option to
list out only /snapshots/, as opposed to subvolumes which weren't
created as a result of a snapshot operation. With such a list, you could
select from the list of snapshot subvolumes, those with lower IDs for
candidate deletion.

I also found in the manpage that 'btrfs subvolume show' will display
extra info that isn't listed in 'btrfs subvolume list', among which is
the subvolume's creation date. It would be a more complicated script,
but issuing 'show' commands on the snapshots reported in the 'list'
command would allow you to build up a list of creation dates for each
snapshot. Then, you could issue 'delete' commands according to some
date-based criterion set by your script.

I don't know if another way to reveal the creation dates of snapshot
subvolumes, but if another method exists, I leave it to others to point out.

In my own use of btrfs subvolumes and snapshotting, I name snapshot
subvolumes using a date-based name scheme, so the subvolume path
implicitly also reveals the date of the snapshot's creation. I also
enjoy the 'send'/'receive' features of btrfs, and I find myself paying
the most attention to the various UUIDs that subvolumes may have. This
allows me to track which parent subvolume UUID a snapshot is created
from, as well as what subvolume a sent/received subvolume relates to.
The UUID scheme btrfs subvolumes use really seems clever, to me. I've
used it to great success in sending incremental changes efficiently to
backup storage, as a given reference subvolume is repeatedly snapshot.

Hope that gives you some insight.

-A

-- 
OpenPGP 0xC6901B2A6C976BB3 (https://keys.openpgp.org)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: what mens gen and ogen in btrfs sub list / ?
  2022-03-24 12:38 what mens gen and ogen in btrfs sub list / ? Lentes, Bernd
  2022-04-14 11:32 ` Andrew Skretvedt
@ 2022-04-14 13:39 ` Nikolay Borisov
  1 sibling, 0 replies; 3+ messages in thread
From: Nikolay Borisov @ 2022-04-14 13:39 UTC (permalink / raw)
  To: Lentes, Bernd, Btrfs ML



On 24.03.22 г. 14:38 ч., Lentes, Bernd wrote:
> 
> Hi,
> 
> i'd like to write a script in which, beneath other stuff, the oldest snapshot(s) are deleted.
> So i'm looking for a way to sort the list of the snapshots by date.
> I read the manpage and stumbled across gen and ogen of snapshots.
> But what does that mean and how can the values be interpreted ?
> Or is there another way to list the snapshots by e.g. creation date ?
> 
> OS: Ubuntu 20.04
> btrfs-progs: 5.4.1-2
> 
> root@nc-mcd:~/skripte# btrfs sub list -tcg /
> ID      gen     cgen    top level       path
> --      ---     ----    ---------       ----
> 273     1060462 170590  5               snapshots/pre_upgrade_27112020
> 279     1060464 1006204 5               snapshots/root-19102021
> 
> 
> Thanks.




So 'gen' is the current transid of the volume, that is the last 
transaction into which  something changed i.e a file was 
created/modified/deleted etc.

cgen OTOH is the transaction when the given subvolume was created.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-04-14 14:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-24 12:38 what mens gen and ogen in btrfs sub list / ? Lentes, Bernd
2022-04-14 11:32 ` Andrew Skretvedt
2022-04-14 13:39 ` Nikolay Borisov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.