Skip to content

Commit

Permalink
fix: added SKIP_DATASETS option to zfs-snapshot.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Dec 18, 2024
1 parent 52204f3 commit d30c6e6
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion home/.bin/zfs-snapshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,24 @@ set -e

# Check if we have permission to destroy snapshots
can_destroy=false
if zfs allow | grep -q "destroy"; then
if zfs allow zroot | grep -q "destroy"; then
can_destroy=true
fi

# Space-separated list of datasets to skip (supports exact matches and patterns)
SKIP_DATASETS="zroot/opt/SteamLibrary"

# Function to check if a dataset should be skipped
should_skip_dataset() {
local dataset=$1
for skip_pattern in $SKIP_DATASETS; do
if [[ "$dataset" == "$skip_pattern" ]]; then
return 0 # Should skip
fi
done
return 1 # Should not skip
}

# Function to create a recursive snapshot
create_snapshot() {
local prefix=$1
Expand All @@ -32,6 +46,10 @@ create_snapshot() {
local snapshot_created=false

for dataset in $datasets; do
if should_skip_dataset "$dataset"; then
echo "Skipping dataset: $dataset"
continue
fi
if ! zfs list -H -t snapshot -o name | grep -q "${dataset}@${snapshot_name}"; then
zfs snapshot "${dataset}@${snapshot_name}"
echo "Created snapshot: ${dataset}@${snapshot_name}"
Expand Down

0 comments on commit d30c6e6

Please sign in to comment.