From d41991979e8d11301df6a37ea30ddd866bde4406 Mon Sep 17 00:00:00 2001 From: expoodo <60551350+expoodo@users.noreply.github.com> Date: Sun, 18 Feb 2024 20:24:13 -0500 Subject: [PATCH 1/4] add support for yabsnap snapshots info --- 41_snapshots-btrfs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/41_snapshots-btrfs b/41_snapshots-btrfs index e63aae1..eb4e02d 100755 --- a/41_snapshots-btrfs +++ b/41_snapshots-btrfs @@ -315,16 +315,24 @@ snapshot_list() fi [[ ! -d "$grub_btrfs_mount_point/$path_snapshot/boot" ]] && continue; # Discard snapshots without /boot folder - # Parse Snapper & timeshift information + # Parse Snapper & timeshift & yabsnap informations local type_snapshot="N/A" local description_snapshot="N/A" + + # path to yabsnap snapshot meta data + local yabsnap_info="$grub_btrfs_mount_point/${path_snapshot%"/"*}/$(echo "${snap[@]:13:1}" | awk -F'/' '{print $3 "-meta.json"}')" + 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" + elif [[ -s $yabsnap_info ]] ; then + type_snapshot=$(grep -P '^\s*"trigger"' $yabsnap_info | awk -F'"' '{print $4}') # search matching string beginning "trigger" + description_snapshot=$(grep -P '^\s*"comment"' $yabsnap_info | awk -F'"' '{print $4}') # search matching string beginning "comment" fi + [[ -z "$type_snapshot" ]] && type_snapshot=("N/A") [[ -z "$description_snapshot" ]] && description_snapshot=("N/A") From a8713bbd0b70298c4054a99936e547f85c83cf85 Mon Sep 17 00:00:00 2001 From: expoodo <60551350+expoodo@users.noreply.github.com> Date: Mon, 19 Feb 2024 15:03:09 -0500 Subject: [PATCH 2/4] mention yabsnap --- README.md | 10 +++++----- config | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d8b48c2..b8e8cdd 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ### 🔎 Description: grub-btrfs improves the grub bootloader by adding a btrfs snapshots sub-menu, allowing the user to boot into snapshots. -grub-btrfs supports manual snapshots as well as snapper and timeshift created snapshots. +grub-btrfs supports manual snapshots as well as snapper, timeshift, and yabsnap created snapshots. ##### Warning: booting read-only snapshots can be tricky @@ -25,7 +25,7 @@ Refer to the [documentation](https://github.com/Antynea/grub-btrfs/blob/master/i * Automatically detect if `/boot` is in a separate partition. * Automatically detect kernel, initramfs and Intel/AMD microcode in `/boot` directory within snapshots. * Automatically create corresponding menu entries in `grub.cfg` -* Automatically detect the type/tags and descriptions/comments of Snapper/Timeshift snapshots. +* Automatically detect the type/tags/triggers and descriptions/comments of Snapper/Timeshift/Yabsnap snapshots. * Automatically generate `grub.cfg` if you use the provided Systemd/ OpenRC service. - - - @@ -97,7 +97,7 @@ The daemon can be configured by passing different command line arguments to it. The available arguments are: * `SNAPSHOTS_DIRS` This argument specifies the (space separated) paths where grub-btrfsd looks for newly created snapshots and snapshot deletions. It is usually defined by the program used to make snapshots. -E.g. for Snapper this would be `/.snapshots`. It is possible to define more than one directory here, all directories will inherit the same settings (recursive etc.). +E.g. for Snapper or Yabsnap this would be `/.snapshots`. It is possible to define more than one directory here, all directories will inherit the same settings (recursive etc.). This argument is not necessary to provide if `--timeshift-auto` is set. * `-c / --no-color` Disable colors in output. @@ -118,7 +118,7 @@ Displays a short help message. ### 🪀 Automatically update grub upon snapshot creation or deletion Grub-btrfsd is a daemon that watches the snapshot directory for you and updates the grub menu automatically every time a snapshot is created or deleted. By default this daemon watches the directory `/.snapshots` for changes (creation or deletion of snapshots) and triggers the grub menu creation and re-installation of grub if any changes are noticed. -Therefore, if Snapper is used with its default directory, the daemon can just be started and nothing needs to be configured. See the instructions below to configure grub-btrfsd for use with Timeshift or when using an alternative snapshots directory with Snapper. +Therefore, if Snapper or Yabsnap is used with its default directory, the daemon can just be started and nothing needs to be configured. See the instructions below to configure grub-btrfsd for use with Timeshift or when using an alternative snapshots directory with Snapper/Yabsnap. - - - #### grub-btrfsd systemd instructions To start the daemon run: @@ -294,7 +294,7 @@ If you have problems with the daemon, you can run it with the `--verbose`-flag. ``` bash sudo /usr/bin/grub-btrfsd --verbose --timeshift-auto` (for timeshift) # or -sudo /usr/bin/grub-btrfsd /.snapshots --verbose` (for snapper) +sudo /usr/bin/grub-btrfsd /.snapshots --verbose` (for snapper/yabsnap) ``` Or pass `--verbose` to the daemon using the Systemd .service file or the OpenRC conf.d file respectively. diff --git a/config b/config index 0329f0a..55f9d35 100644 --- a/config +++ b/config @@ -81,6 +81,8 @@ GRUB_BTRFS_IGNORE_PREFIX_PATH=("var/lib/docker" "@var/lib/docker" "@/var/lib/doc # Type = single, pre, post. # For Timeshift: # Tag = boot, ondemand, hourly, daily, weekly, monthly. +# For yabsnap: +# Trigger = S, I, U. # Default: ("") #GRUB_BTRFS_IGNORE_SNAPSHOT_TYPE=("") From 34b54de71c832f722a7545773a2526a44d5e8ace Mon Sep 17 00:00:00 2001 From: expoodo <60551350+expoodo@users.noreply.github.com> Date: Mon, 19 Feb 2024 15:16:26 -0500 Subject: [PATCH 3/4] removed redundant array slice --- 41_snapshots-btrfs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/41_snapshots-btrfs b/41_snapshots-btrfs index eb4e02d..0e75bd2 100755 --- a/41_snapshots-btrfs +++ b/41_snapshots-btrfs @@ -320,7 +320,7 @@ snapshot_list() local description_snapshot="N/A" # path to yabsnap snapshot meta data - local yabsnap_info="$grub_btrfs_mount_point/${path_snapshot%"/"*}/$(echo "${snap[@]:13:1}" | awk -F'/' '{print $3 "-meta.json"}')" + local yabsnap_info="$grub_btrfs_mount_point/${path_snapshot%"/"*}/$(echo "${snap[13]}" | awk -F'/' '{print $3 "-meta.json"}')" 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" From b8465d14dbcb9dcee875a8acba277fdcaf330133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20J=C3=A4ger?= Date: Wed, 6 Mar 2024 14:43:57 +0100 Subject: [PATCH 4/4] fix spelling --- 41_snapshots-btrfs | 2 +- config | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/41_snapshots-btrfs b/41_snapshots-btrfs index d508f59..e1e183b 100755 --- a/41_snapshots-btrfs +++ b/41_snapshots-btrfs @@ -315,7 +315,7 @@ snapshot_list() fi [ ! -d "$grub_btrfs_mount_point/$path_snapshot/boot" ] && continue; # Discard snapshots without /boot folder - # Parse Snapper & timeshift & yabsnap informations + # Parse Snapper & timeshift & yabsnap information local type_snapshot="N/A" local description_snapshot="N/A" diff --git a/config b/config index 0e99c96..03f8f4e 100644 --- a/config +++ b/config @@ -1,7 +1,7 @@ #!/usr/bin/env bash -GRUB_BTRFS_VERSION=4.13-fix_bashism-2024-03-06T13:23:26+00:00 +GRUB_BTRFS_VERSION=4.13-yabsnap_info_support-2024-03-06T13:43:57+00:00 # Disable grub-btrfs. # Default: "false"