I'm writing a bash backup script, which creates BTRFS subvolume snapshots on a mounted volume (i.e. /mnt/btrfs/subvolume). As usual I would use "lsof /mnt/btrfs/subvolume" and pipe its output to something like "awk 'NR==1 || $4~/[0-9][uw]/'", so I can see if there are any changing files.
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
sh 5019 root 1w REG 8,35 2088960 12 /mnt/ext4/currently_generated_archive.tar.xz
This will not work on BTRFS the same way and does not return open files for writing. My best guess is that BTRFS subvolumes use "Copy on Write" and thus kernel/lsof is somehow fooled and not showing these changes. Does anyone know, how I can check if any files are being changed/written under mounted BTRFS subvolume?
Regards