diff --git a/pacman-zfs-snapshot.sh b/pacman-zfs-snapshot.sh index 647a644..0b46e07 100755 --- a/pacman-zfs-snapshot.sh +++ b/pacman-zfs-snapshot.sh @@ -43,6 +43,20 @@ function set_severity () { fi } +function get_globally_snappable_datasets () { + local datasets_list + # For all datasets show their 'space.quico:auto-snapshot' property; only + # print dataset name in column 1 and property value in column 2. In awk + # limit this list to datasets where tab-delimited column 2 has exact + # string '^true$' then further limit output by eliminating snapshots + # from list, i.e. dataset names that contain an '@' character. + datasets_list="$(zfs get -H -o 'name,value' 'space.quico:auto-snapshot' | \ + awk -F'\t' '{if($2 ~ /^true$/ && $1 !~ /@/) print $1}')" + while IFS= read -r dataset; do + globally_snappable_datasets+=("${dataset}") + done <<<"${datasets_list}" +} + function write_pkg_list_oneline () { local unabridged_pkg_list_oneline if [[ "${severity}" == 'imp' ]]; then @@ -75,6 +89,9 @@ function main () { local severity set_severity + local -a globally_snappable_datasets + get_globally_snappable_datasets + local pkg_list_oneline write_pkg_list_oneline