Skip to content

Instantly share code, notes, and snippets.

@NyaMisty
Created February 23, 2024 14:36
Show Gist options
  • Save NyaMisty/18a4b03fd3be41f85dcfec1721a9624d to your computer and use it in GitHub Desktop.
Save NyaMisty/18a4b03fd3be41f85dcfec1721a9624d to your computer and use it in GitHub Desktop.
Recursively mount ZFS snapshot for a dataset
#!/bin/bash
# Change these parameters
mntdir=/mnt/cache/_tmp_restic-snapshot
dataset_name="cache"
datasets=($(zfs list -t filesystem -H | cut -d$'\t' -f1 | grep -E '^'$dataset_name'(/|$)'))
echo "Datasets selected: ${datasets[@]}"
for d in "${datasets[@]}"; do
mntsubdir=${d#"$dataset_name"}
echo "Mounting dataset $d to ${mntdir}/${mntsubdir}"
mount -t zfs ${d}@restic_bak_snapshot "${mntdir}/${mntsubdir}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment