I wrote and maintain a set of Dolphin Service Menus to allow some btrfs functionality to be accessible from Dolphin.
I am adding the ability to determine if a "btrfs send|btrfs receive" operation was successful. The success or failure is is indicated by two items retrievable from "btrfs su show". They are "Received UUID:" followed by a UUID and "FLAGS:" followed by "readonly". Both entries are only set if the send|receive operation completes successfully.
One uses the "btrfs su show" action to see the full list of subvolume information, which looks like this:
If the send|receive operation fails, the fields after "Received UUID" and "Flags:" have a dash in them instead of the above.
The question: Is there a preferred or "better" way to extract this information from the above output?
Currently, I'm using:
$SOURCE is the full path and filename of the selected subvolume. The above awk statements retrieve the Received UUID and "readonly" from Flags, and it works.
I then use a conditional "if - or" to check for the dash instead of anything else:
so if either entry is not set, the script reports that it failed or wasn't a "sent" snapshot.
I feel like there must be a handful of other ways to scrape the info. Mostly, I'm just curious, but having "solid" code is always a good idea.
Thoughts?
I am adding the ability to determine if a "btrfs send|btrfs receive" operation was successful. The success or failure is is indicated by two items retrievable from "btrfs su show". They are "Received UUID:" followed by a UUID and "FLAGS:" followed by "readonly". Both entries are only set if the send|receive operation completes successfully.
One uses the "btrfs su show" action to see the full list of subvolume information, which looks like this:
Code:
sudo btrfs su show @KDEneon_backup Name: @KDEneon_backup UUID: 00983575-f97d-d942-9537-f4c8c29bc77a Parent UUID: 0bef4f24-2620-7443-84d2-43c82a79e690 Received UUID: 16716210-06d4-ea42-9048-7449068cb643 Creation time: 2026-10-06 05:39:35 -0400 Subvolume ID: 2246 Generation: 14825 Gen at creation: 14820 Parent ID: 5 Top level ID: 5 Flags: readonly Send transid: 2145521 Send time: 2026-10-06 05:39:35 -0400 Receive transid: 14821 Receive time: 2026-10-06 05:39:36 -0400 Snapshot(s): Quota group: n/a
The question: Is there a preferred or "better" way to extract this information from the above output?
Currently, I'm using:
Code:
RECEIVED_UUID=`sudo -S btrfs su sh $SOURCE | awk 'NR >4 && NR<=5 {print $3}'`
READONLY_FLAG=`sudo -S btrfs su sh $SOURCE | awk 'NR >11 && NR<=12 {print $2}'`
I then use a conditional "if - or" to check for the dash instead of anything else:
Code:
if [[ $RECEIVED_UUID == '-' || $READONLY_FLAG == '-' ]]; then
I feel like there must be a handful of other ways to scrape the info. Mostly, I'm just curious, but having "solid" code is always a good idea.
Thoughts?







Comment