Skip to content
This repository has been archived by the owner on Mar 7, 2022. It is now read-only.

Commit

Permalink
restore, set permissions as dest folder
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenverhoef committed Mar 19, 2020
1 parent b18246d commit feab529
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions freenas-jails.sh
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,9 @@ install_jail () {
if [ -d "$BACKUP_LOCATION/$JAIL/usr/local/etc/letsencrypt/" ]; then # copy certificates before installing, otherwise certificates will be requested when not necessary
echo "restoring certificates..."
mkdir -p $JAIL_LOCATION/$JAIL/root/usr/local/etc/letsencrypt
rsync -o $USER_NAME -g $USER_NAME -a $BACKUP_LOCATION/$JAIL/usr/local/etc/letsencrypt/ $JAIL_LOCATION/$JAIL/root/usr/local/etc/letsencrypt
USER=$(stat -f %Su $JAIL_LOCATION/$JAIL/root/usr/local/etc/letsencrypt)
GROUP=$(stat -f %Sg $JAIL_LOCATION/$JAIL/root/usr/local/etc/letsencrypt)
rsync -a $BACKUP_LOCATION/$JAIL/usr/local/etc/letsencrypt/ $JAIL_LOCATION/$JAIL/root/usr/local/etc/letsencrypt --chown=$USER:$GROUP
fi

if grep -q "MYSQL.*_DATABASE" $JAIL_CONFIG; then # configure mysql if needed
Expand Down Expand Up @@ -478,7 +480,9 @@ install_jail () {
DEST_FOLDER=${DEST_FOLDER%/*}/
(( i++ ))
if [ "$FOLDER" ]; then
rsync -o $USER_NAME -g $USER_NAME -a $BACKUP_LOCATION/$JAIL$FOLDER $JAIL_LOCATION/$JAIL/root$DEST_FOLDER
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
Expand Down

0 comments on commit feab529

Please sign in to comment.