diff options
author | Max Christian Pohle | 2021-03-24 18:54:21 +0100 |
---|---|---|
committer | Max Christian Pohle | 2021-03-24 18:54:21 +0100 |
commit | 9c4589ac2fd8c9db921c51e921a9fbfc5c3efa4f (patch) | |
tree | ab70844a272e314f9b7125a37197e60096069b9a | |
parent | f1ab24e775479eabbad928d889f7c0cfe792d7c5 (diff) | |
download | zfs-bash-tools-9c4589ac2fd8c9db921c51e921a9fbfc5c3efa4f.tar.bz2 zfs-bash-tools-9c4589ac2fd8c9db921c51e921a9fbfc5c3efa4f.zip |
Made squash script FreeBSD compatible
-rwxr-xr-x | zfs-squash-datasets.sh | 9 |
1 files 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 @@ | |||
1 | #!/usr/local/bin/bash | ||
1 | DATASET_ROOT=$1 | 2 | DATASET_ROOT=$1 |
2 | DATASET_TARGET=$2 | 3 | DATASET_TARGET=$2 |
3 | 4 | ||
4 | MOUNTPOINT_TARGET=$(zfs get -H mountpoint -o value $DATASET_TARGET) | 5 | MOUNTPOINT_TARGET=$(zfs get -o value -H mountpoint $DATASET_TARGET) |
5 | 6 | ||
6 | if ! test -d "$MOUNTPOINT_TARGET"; then | 7 | if ! test -d "$MOUNTPOINT_TARGET"; then |
7 | echo "Please run this program with a source and a target dataset name as arguments" | 8 | echo "Please run this program with a source and a target dataset name as arguments" |
@@ -13,8 +14,8 @@ fi | |||
13 | trap exit INT | 14 | trap exit INT |
14 | 15 | ||
15 | # recursively contains all snapshot names (the part after the @) from root on, sorted and only once | 16 | # recursively contains all snapshot names (the part after the @) from root on, sorted and only once |
16 | SNAPSHOTS=$(zfs list -H -r $DATASET_ROOT -oname -tsnap | cut -d@ -f2 | sort | uniq) | 17 | SNAPSHOTS=$(zfs list -H -oname -tsnap -r $DATASET_ROOT| cut -d@ -f2 | sort | uniq) |
17 | DATASETS=$(zfs list -H -r $DATASET_ROOT -oname -t filesystem) | 18 | DATASETS=$(zfs list -H -oname -t filesystem -r $DATASET_ROOT) |
18 | 19 | ||
19 | echo "We are going to flatten the hierachy of this dataset:" | 20 | echo "We are going to flatten the hierachy of this dataset:" |
20 | printf " %s\n" $DATASETS | 21 | printf " %s\n" $DATASETS |
@@ -35,7 +36,7 @@ for SNAPSHOT in $SNAPSHOTS; do | |||
35 | 36 | ||
36 | for DATASET in $DATASETS; do | 37 | for DATASET in $DATASETS; do |
37 | 38 | ||
38 | MOUNTPOINT=$(zfs get -H mountpoint -o value $DATASET) | 39 | MOUNTPOINT=$(zfs get -H -o value mountpoint $DATASET) |
39 | 40 | ||
40 | if [[ $MOUNTPOINT == "legacy" ]]; then | 41 | if [[ $MOUNTPOINT == "legacy" ]]; then |
41 | MOUNTPOINT=$(findmnt -n -o target $DATASET) | 42 | MOUNTPOINT=$(findmnt -n -o target $DATASET) |