btrbk is a script for automating btrfs backups using snapshots and send/receive. It has a "backend" btrfs-progs-btrbk, which is a patchset for btrfs-progs and is used to create individual binaries, eg. btrfs-subvolume-show, btrfs-subvolume-list, etc. The point of these binaries is to allow privilege separation using capabilities(7) so btrfs itself doesn't need to be given root privileges when btrbk is run as a cron script, only a few subcommands.

I am confused why the patchset, rather than simply a series of scripts for each of these commands. After all, btrbk itself is a pearl script. Does anyone have any insight?

2 Answers 2


Where do you think btrfs-subvolume-show comes from? Rebuilding btrfs-progs split out like that. Magically refactoring a monolithic C program into many is not practical from a Perl script.

Compare that repo to an earlier version of itself say tag 5.1. Note the changes to Makefile targets for "separated", comment metadata for which functions go in which binaries, and a bunch of #ifdefs to make it optional. I don't know the history here, but patch sets this clever can take a while to be accepted upstream.

  • Wait, but this is about privilege separation. To make that work with btrfs-subvolume-show, why not just a script: #! /bin/bash, btrfs subvolume show $1, and then set capabilities on that script?
    – Diagon
    May 16, 2021 at 20:04
  • 1
    You covered setcap shell scripts in your answer, they are not practical. Which is ultimately why this patch set exists, to make single purpose binaries that can be given specific capabilities. May 17, 2021 at 20:43

Ok, it's a matter of security. Quoting the author of btrbk,

... enabling setcap on scripts is a bad idea (you really don't want to setcap your shell interpreter, I think it's not even possible on most systems), and you would need to set the "Inheritable" capabilities(7) bit.

He's tried to get his patches merged upstream, but with little luck so far.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .