Created
February 23, 2024 14:36
-
-
Save NyaMisty/18a4b03fd3be41f85dcfec1721a9624d to your computer and use it in GitHub Desktop.
Recursively mount ZFS snapshot for a dataset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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