linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Used disk size of a received subvolume?
@ 2019-05-16 14:54 Axel Burri
  2019-05-16 17:09 ` Remi Gauvin
  2019-05-16 17:12 ` Hugo Mills
  0 siblings, 2 replies; 10+ messages in thread
From: Axel Burri @ 2019-05-16 14:54 UTC (permalink / raw)
  To: linux-btrfs

Trying to get the size of a subvolume created using "btrfs receive",
I've come with a cute little script:

   SUBVOL=/path/to/subvolume
   CGEN=$(btrfs subvolume show "$SUBVOL" \
     | sed -n 's/\s*Gen at creation:\s*//p')
   btrfs subvolume find-new "$SUBVOL" $((CGEN+1)) \
     | cut -d' ' -f7 \
     | tr '\n' '+' \
     | sed 's/\+\+$/\n/' \
     | bc

This simply sums up the "len" field from all modified files since the
creation of the subvolume. Works fine, as btrfs-receive first makes a
snapshot of the parent subvolume, then adds the files according to the
send-stream.

Now this rises some questions:

1. How accurate is this? AFAIK "btrfs find-new" prints real length, not
compressed length.

2. If there are clone-sources in the send-stream, the cloned files
probably also appear in the list.

3. Is there a better way? It would be nice to have a btrfs command for
this. It would be straight-forward to have a "--summary" option in
"btrfs find-new", another approach would be to calculate and dump the
size in either "btrfs send" or "btrfs receive".

Any thoughts? I'm willing to implement such a feature in btrfs-progs if
this sounds reasonable to you.


- Axel


Ref: https://github.com/digint/btrbk/issues/280

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

end of thread, other threads:[~2019-05-23 16:06 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-16 14:54 Used disk size of a received subvolume? Axel Burri
2019-05-16 17:09 ` Remi Gauvin
2019-05-17 14:14   ` Axel Burri
2019-05-17 16:22     ` Remi Gauvin
2019-05-16 17:12 ` Hugo Mills
2019-05-17 13:57   ` Axel Burri
2019-05-17 15:28     ` Graham Cobb
2019-05-17 16:39       ` Steven Davies
2019-05-17 23:15         ` Graham Cobb
2019-05-23 16:06       ` Axel Burri

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).