Have a look at my macOS scripts:
It is working for me very well. I know it is not BTRFS but it is the same idea anyway.