digint / btrbk

Tool for creating snapshots and remote backups of btrfs subvolumes
https://digint.ch/btrbk/
GNU General Public License v3.0
1.64k stars 120 forks source link

Feature request: Generate metadata #484

Open kjkent opened 2 years ago

kjkent commented 2 years ago

Hi there. Btrbk is fantastic; after getting it set up and working with grub-btrfs it feels like such a great safety net and is such a better experience than other tools.

One thing I noticed, is that grub-btrfs parses metadata from Snapper and Timeshift that allows it to display snapshot info like a title/description. It does so with the following code:

# Parse Snapper & timeshift informations
        local type_snapshot="N/A"
        local description_snapshot="N/A"
        if [[ -s "$grub_btrfs_mount_point/${path_snapshot%"/"*}/$snapper_info" ]] ; then
            type_snapshot=$(awk -F"<|>" 'match($2, /^type/) {print $3}' "$grub_btrfs_mount_point/${path_snapshot%"/"*}/$snapper_info") # search matching string beginning "type"
            description_snapshot=$(awk -F"<|>" 'match($2, /^description/) {print $3}' "$grub_btrfs_mount_point/${path_snapshot%"/"*}/$snapper_info") # search matching string beginning "description"
        elif [[ -s "$grub_btrfs_mount_point/${path_snapshot%"/"*}/$timeshift_info" ]] ; then
            type_snapshot=$(awk -F" : " 'match($1, /^[ \t]+"tags"/) {gsub(/"|,/,"");print $2}' "$grub_btrfs_mount_point/${path_snapshot%"/"*}/$timeshift_info") # search matching string beginning "tags"
            description_snapshot=$(awk -F" : " 'match($1, /^[ \t]+"comments"/) {gsub(/"|,/,"");print $2}' "$grub_btrfs_mount_point/${path_snapshot%"/"*}/$timeshift_info") # search matching string beginning "comments"
        fi
        [[ -z "$type_snapshot" ]] && type_snapshot=("N/A")
        [[ -z "$description_snapshot" ]] && description_snapshot=("N/A")

It seems like it would be trivial to add deeper support in grub-btrbk for btrbk, if you were interested in having functionality for btrbk to have a flag for manual runs which facilitated the input of user input, for instance?

I think it would be useful in case a user ran a manual backup, it would make their snapshots more easily identifiable.

Just a thought. Thanks again for producing this great bit of software.

digint commented 2 years ago

btrbk by design does not write any metadata (with some exceptions with raw backups), as this complicates things a lot and is usually not required.

That does not mean that it would not be possible to have an additional script, e.g. by calling btrbk list with correct formatting options.

Please give some more information about grub-btrfs and how you think it should look like: I'd love to have some kind of grub support as well, at the moment I'm half-happily changing things manually in grub if e.g. I want to boot off a separate snapshot