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.

Revisions

  1. NyaMisty created this gist Feb 23, 2024.
    13 changes: 13 additions & 0 deletions mount_zfs_snapshot.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    #!/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