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