Skip to content

Commit 346a986

Browse files
authored
Merge pull request #318 from expoodo/yabsnap_info_support
add support for yabsnap snapshot information
2 parents 94d742d + b8465d1 commit 346a986

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

41_snapshots-btrfs

+9-1
Original file line numberDiff line numberDiff line change
@@ -315,16 +315,24 @@ snapshot_list()
315315
fi
316316
[ ! -d "$grub_btrfs_mount_point/$path_snapshot/boot" ] && continue; # Discard snapshots without /boot folder
317317

318-
# Parse Snapper & timeshift information
318+
# Parse Snapper & timeshift & yabsnap information
319319
local type_snapshot="N/A"
320320
local description_snapshot="N/A"
321+
322+
# path to yabsnap snapshot meta data
323+
local yabsnap_info="$grub_btrfs_mount_point/${path_snapshot%"/"*}/$(echo "${snap[13]}" | awk -F'/' '{print $3 "-meta.json"}')"
324+
321325
if [[ -s "$grub_btrfs_mount_point/${path_snapshot%"/"*}/$snapper_info" ]] ; then
322326
type_snapshot=$(awk -F"<|>" 'match($2, /^type/) {print $3}' "$grub_btrfs_mount_point/${path_snapshot%"/"*}/$snapper_info") # search matching string beginning "type"
323327
description_snapshot=$(awk -F"<|>" 'match($2, /^description/) {print $3}' "$grub_btrfs_mount_point/${path_snapshot%"/"*}/$snapper_info") # search matching string beginning "description"
324328
elif [[ -s "$grub_btrfs_mount_point/${path_snapshot%"/"*}/$timeshift_info" ]] ; then
325329
type_snapshot=$(awk -F" : " 'match($1, /^[ \t]+"tags"/) {gsub(/"|,/,"");print $2}' "$grub_btrfs_mount_point/${path_snapshot%"/"*}/$timeshift_info") # search matching string beginning "tags"
326330
description_snapshot=$(awk -F" : " 'match($1, /^[ \t]+"comments"/) {gsub(/"|,/,"");print $2}' "$grub_btrfs_mount_point/${path_snapshot%"/"*}/$timeshift_info") # search matching string beginning "comments" fix '
331+
elif [[ -s $yabsnap_info ]] ; then
332+
type_snapshot=$(grep -P '^\s*"trigger"' $yabsnap_info | awk -F'"' '{print $4}') # search matching string beginning "trigger"
333+
description_snapshot=$(grep -P '^\s*"comment"' $yabsnap_info | awk -F'"' '{print $4}') # search matching string beginning "comment"
327334
fi
335+
328336
[ -z "$type_snapshot" ] && type_snapshot=("N/A")
329337
[ -z "$description_snapshot" ] && description_snapshot=("N/A")
330338

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
### 🔎 Description:
99
grub-btrfs improves the grub bootloader by adding a btrfs snapshots sub-menu, allowing the user to boot into snapshots.
1010

11-
grub-btrfs supports manual snapshots as well as snapper and timeshift created snapshots.
11+
grub-btrfs supports manual snapshots as well as snapper, timeshift, and yabsnap created snapshots.
1212

1313
##### Warning: booting read-only snapshots can be tricky
1414

@@ -25,7 +25,7 @@ Refer to the [documentation](https://github.com/Antynea/grub-btrfs/blob/master/i
2525
* Automatically detect if `/boot` is in a separate partition.
2626
* Automatically detect kernel, initramfs and Intel/AMD microcode in `/boot` directory within snapshots.
2727
* Automatically create corresponding menu entries in `grub.cfg`
28-
* Automatically detect the type/tags and descriptions/comments of Snapper/Timeshift snapshots.
28+
* Automatically detect the type/tags/triggers and descriptions/comments of Snapper/Timeshift/Yabsnap snapshots.
2929
* Automatically generate `grub.cfg` if you use the provided Systemd/ OpenRC service.
3030

3131
- - -
@@ -97,7 +97,7 @@ The daemon can be configured by passing different command line arguments to it.
9797
The available arguments are:
9898
* `SNAPSHOTS_DIRS`
9999
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.
100-
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.).
100+
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.).
101101
This argument is not necessary to provide if `--timeshift-auto` is set.
102102
* `-c / --no-color`
103103
Disable colors in output.
@@ -118,7 +118,7 @@ Displays a short help message.
118118
### 🪀 Automatically update grub upon snapshot creation or deletion
119119
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.
120120
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.
121-
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.
121+
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.
122122
- - -
123123
#### grub-btrfsd systemd instructions
124124
To start the daemon run:
@@ -294,7 +294,7 @@ If you have problems with the daemon, you can run it with the `--verbose`-flag.
294294
``` bash
295295
sudo /usr/bin/grub-btrfsd --verbose --timeshift-auto` (for timeshift)
296296
# or
297-
sudo /usr/bin/grub-btrfsd /.snapshots --verbose` (for snapper)
297+
sudo /usr/bin/grub-btrfsd /.snapshots --verbose` (for snapper/yabsnap)
298298
```
299299
Or pass `--verbose` to the daemon using the Systemd .service file or the OpenRC conf.d file respectively.
300300

config

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

33

4-
GRUB_BTRFS_VERSION=4.13-fix_bashism-2024-03-06T13:23:26+00:00
4+
GRUB_BTRFS_VERSION=4.13-yabsnap_info_support-2024-03-06T13:43:57+00:00
55

66
# Disable grub-btrfs.
77
# Default: "false"
@@ -81,6 +81,8 @@ GRUB_BTRFS_IGNORE_PREFIX_PATH=("var/lib/docker" "@var/lib/docker" "@/var/lib/doc
8181
# Type = single, pre, post.
8282
# For Timeshift:
8383
# Tag = boot, ondemand, hourly, daily, weekly, monthly.
84+
# For yabsnap:
85+
# Trigger = S, I, U.
8486
# Default: ("")
8587
#GRUB_BTRFS_IGNORE_SNAPSHOT_TYPE=("")
8688

0 commit comments

Comments
 (0)