From 9c4589ac2fd8c9db921c51e921a9fbfc5c3efa4f Mon Sep 17 00:00:00 2001 From: Max Christian Pohle Date: Wed, 24 Mar 2021 18:54:21 +0100 Subject: Made squash script FreeBSD compatible --- zfs-squash-datasets.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/zfs-squash-datasets.sh b/zfs-squash-datasets.sh index c61af40..d668c80 100755 --- a/zfs-squash-datasets.sh +++ b/zfs-squash-datasets.sh @@ -1,7 +1,8 @@ +#!/usr/local/bin/bash DATASET_ROOT=$1 DATASET_TARGET=$2 -MOUNTPOINT_TARGET=$(zfs get -H mountpoint -o value $DATASET_TARGET) +MOUNTPOINT_TARGET=$(zfs get -o value -H mountpoint $DATASET_TARGET) if ! test -d "$MOUNTPOINT_TARGET"; then echo "Please run this program with a source and a target dataset name as arguments" @@ -13,8 +14,8 @@ fi trap exit INT # recursively contains all snapshot names (the part after the @) from root on, sorted and only once -SNAPSHOTS=$(zfs list -H -r $DATASET_ROOT -oname -tsnap | cut -d@ -f2 | sort | uniq) -DATASETS=$(zfs list -H -r $DATASET_ROOT -oname -t filesystem) +SNAPSHOTS=$(zfs list -H -oname -tsnap -r $DATASET_ROOT| cut -d@ -f2 | sort | uniq) +DATASETS=$(zfs list -H -oname -t filesystem -r $DATASET_ROOT) echo "We are going to flatten the hierachy of this dataset:" printf " %s\n" $DATASETS @@ -35,7 +36,7 @@ for SNAPSHOT in $SNAPSHOTS; do for DATASET in $DATASETS; do - MOUNTPOINT=$(zfs get -H mountpoint -o value $DATASET) + MOUNTPOINT=$(zfs get -H -o value mountpoint $DATASET) if [[ $MOUNTPOINT == "legacy" ]]; then MOUNTPOINT=$(findmnt -n -o target $DATASET) -- cgit v1.2.3