zsc.sh: allow disabling snapshot creation
This commit is contained in:
parent
1bca577ede
commit
06a1b7aec7
27
zsc.sh
27
zsc.sh
@ -22,12 +22,13 @@ split_date() {
|
|||||||
|
|
||||||
handle_dataset() {
|
handle_dataset() {
|
||||||
DATASET=$1
|
DATASET=$1
|
||||||
D=$2
|
AUTO_CREATE=$2
|
||||||
W=$3
|
D=$3
|
||||||
M=$4
|
W=$4
|
||||||
Y=$5
|
M=$5
|
||||||
|
Y=$6
|
||||||
|
|
||||||
PREFIX=$6
|
PREFIX=$7
|
||||||
if test -z "$PREFIX"; then
|
if test -z "$PREFIX"; then
|
||||||
PREFIX="zsc-"
|
PREFIX="zsc-"
|
||||||
fi
|
fi
|
||||||
@ -75,25 +76,29 @@ handle_dataset() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
if [ $EXISTS -eq 0 ]; then
|
if [ $EXISTS -eq 0 ]; then
|
||||||
echo -e "Creating snapshot $DATASET@$PREFIX$DATE"
|
if [ $AUTO_CREATE == "true" ]; then
|
||||||
zfs snapshot $DATASET@$PREFIX$DATE
|
echo -e "Creating snapshot $DATASET@$PREFIX$DATE"
|
||||||
|
zfs snapshot $DATASET@$PREFIX$DATE
|
||||||
|
else
|
||||||
|
echo -e "Skip snapshot creation"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
cat "$CONFIG_FILE" | while IFS=: read dataset recursive d w m y prefix; do
|
cat "$CONFIG_FILE" | while IFS=: read dataset recursive auto_create d w m y prefix; do
|
||||||
echo "| ##### Dataset: $dataset Recursive: $recursive Prefix: $prefix d: $d w: $w m: $m y: $y #####"
|
echo "| ##### Dataset: $dataset Recursive: $recursive Auto create: $auto_create Prefix: $prefix d: $d w: $w m: $m y: $y #####"
|
||||||
|
|
||||||
if [ $recursive = "true" ]; then
|
if [ $recursive = "true" ]; then
|
||||||
SUBDATASETS=($(zfs list -o name | grep "$dataset/"))
|
SUBDATASETS=($(zfs list -o name | grep "$dataset/"))
|
||||||
echo -e "| Subdatasets: ${SUBDATASETS[@]}"
|
echo -e "| Subdatasets: ${SUBDATASETS[@]}"
|
||||||
echo -e '|'
|
echo -e '|'
|
||||||
for p in "${SUBDATASETS[@]}"; do
|
for p in "${SUBDATASETS[@]}"; do
|
||||||
handle_dataset $p $d $w $m $y $prefix | awk '{print "| " $0}'
|
handle_dataset $p $auto_create $d $w $m $y $prefix | awk '{print "| " $0}'
|
||||||
echo -e '|'
|
echo -e '|'
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
handle_dataset $dataset $d $w $m $y $prefix | awk '{print "| " $0}'
|
handle_dataset $dataset $auto_create $d $w $m $y $prefix | awk '{print "| " $0}'
|
||||||
|
|
||||||
echo -e "----------------------------------------------------------------------"
|
echo -e "----------------------------------------------------------------------"
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user