From 82a001896a5b85c63a3475c8f3996f081206b065 Mon Sep 17 00:00:00 2001 From: Ruben Verhoef Date: Thu, 19 Mar 2020 20:36:04 +0100 Subject: [PATCH] #12 restore files before and after configuring --- freenas-jails.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/freenas-jails.sh b/freenas-jails.sh index 53efddb..7e5c692 100644 --- a/freenas-jails.sh +++ b/freenas-jails.sh @@ -448,6 +448,21 @@ install_jail () { rm -rf $JAIL_LOCATION/webserver/root/root/${!MYSQL_DATA}.sql fi fi + + i=1 + while true; do + FOLDER="$(sed -n ''$i'p' ${JAIL_CONFIG%/*}/backup.conf)" + DEST_FOLDER="$(sed -n ''$i'p' ${JAIL_CONFIG%/*}/backup.conf | cut -d " " -f1)" + DEST_FOLDER=${DEST_FOLDER%/*}/ + (( i++ )) + if [ "$FOLDER" ]; then + USER=$(stat -f %Su $(dirname $JAIL_LOCATION/$JAIL/root$DEST_FOLDER)) + GROUP=$(stat -f %Sg $(dirname $JAIL_LOCATION/$JAIL/root$DEST_FOLDER)) + rsync -a $BACKUP_LOCATION/$JAIL$FOLDER $JAIL_LOCATION/$JAIL/root$DEST_FOLDER --chown=$USER:$GROUP + else + break + fi + done fi fi