Skip to content

Commit

Permalink
Add filter snapper's snapshot (#158)
Browse files Browse the repository at this point in the history
- Add filter to ignore snapper's snapshot "type or description" during run "grub-mkconfig"

- Two new variables available in the config file:
# Ignore specific type of snapper's snapshot during run "grub-mkconfig".
# Type = single, pre or post.
# Default: ("")
GRUB_BTRFS_IGNORE_SNAPPER_TYPE=("")

# Ignore specific description of snapper's snapshot during run "grub-mkconfig".
# Default: ("")
GRUB_BTRFS_IGNORE_SNAPPER_DESCRIPTION=("")
  • Loading branch information
Antynea authored Jul 14, 2021
1 parent 3433754 commit 981777d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
12 changes: 12 additions & 0 deletions 41_snapshots-btrfs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,18 @@ snapshot_list()
if [[ "$snapper_id" == "$id" ]]; then
local snapper_type=$(trim "${snapper_types[$j]}")
local snapper_description=$(trim "${snapper_descriptions[$j]}")

# ignore snapper_type or snapper_description during run "grub-mkconfig"
if [ ! -z "${GRUB_BTRFS_IGNORE_SNAPPER_TYPE}" ] ; then
for ist in ${GRUB_BTRFS_IGNORE_SNAPPER_TYPE[@]} ; do
[[ "${snapper_type}" == "${ist}" ]] && continue 3;
done
fi
if [ ! -z "${GRUB_BTRFS_IGNORE_SNAPPER_DESCRIPTION}" ] ; then
for isd in ${GRUB_BTRFS_IGNORE_SNAPPER_DESCRIPTION[@]} ; do
[[ "${snapper_description}" == "${isd}" ]] && continue 3;
done
fi
printf -v entry "%-${max_entry_length}s | %-${max_type_length}s | %s" "$entry" "$snapper_type" "$snapper_description"
break
fi
Expand Down
9 changes: 9 additions & 0 deletions config
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ GRUB_BTRFS_IGNORE_SPECIFIC_PATH=("@")
# Default: ("var/lib/docker" "@var/lib/docker" "@/var/lib/docker")
GRUB_BTRFS_IGNORE_PREFIX_PATH=("var/lib/docker" "@var/lib/docker" "@/var/lib/docker")

# Ignore specific type of snapper's snapshot during run "grub-mkconfig".
# Type = single, pre, post.
# Default: ("")
GRUB_BTRFS_IGNORE_SNAPPER_TYPE=("")

# Ignore specific description of snapper's snapshot during run "grub-mkconfig".
# Default: ("")
GRUB_BTRFS_IGNORE_SNAPPER_DESCRIPTION=("")

# By default "grub-btrfs" automatically detects your boot partition,
# either located at the system root or on a separate partition,
# but cannot detect if it is in a subvolume.
Expand Down

0 comments on commit 981777d

Please sign in to comment.