don't allow the Nextcloud container to start if the update failed

Signed-off-by: szaimen <szaimen@e.mail.de>
This commit is contained in:
szaimen 2022-08-15 14:00:48 +02:00
parent 1411a0d8b1
commit 9f6c532170
3 changed files with 19 additions and 0 deletions

View file

@ -152,6 +152,11 @@ if [ "$BORG_MODE" = backup ]; then
# Inform user
get_expiration_time
echo "Backup finished successfully on $END_DATE_READABLE ($DURATION_READABLE)"
if [ -f "/nextcloud_aio_volumes/nextcloud_aio_nextcloud_data/update.failed" ]; then
echo "However a Nextcloud update failed. So reporting that the backup failed which will skip any update attempt the next time."
echo "Please restore a backup from before the failed Nextcloud update attempt."
exit 1
fi
exit 0
fi

View file

@ -69,6 +69,10 @@ if [ "$DAILY_BACKUP" = 1 ]; then
while docker ps --format "{{.Names}}" | grep -q "^nextcloud-aio-nextcloud$" && ! nc -z nextcloud-aio-nextcloud 9000; do
echo "Waiting for the Nextcloud container to start"
sleep 30
if [ "$(docker inspect nextcloud-aio-nextcloud --format "{{.State.Restarting}}")" = "true" ]; then
echo "Nextcloud container restarting. Skipping this check!"
break
fi
done
fi
sudo -u www-data php /var/www/docker-aio/php/src/Cron/BackupNotification.php

View file

@ -57,6 +57,14 @@ if [ -f "/var/www/html/lib/versioncheck.php" ] && ! php /var/www/html/lib/versio
exit 1
fi
# Do not start the container if the last update failed
if [ -f "/mnt/ncdata/update.failed" ]; then
echo "The last Nextcloud update failed."
echo "Please restore from backup and try again!"
echo "If you do not have a backup in place, you can simply delete the update.failed file in the datadir which will allow the container to start again."
exit 1
fi
# Skip any update if Nextcloud was just restored
if ! [ -f "/mnt/ncdata/skip.update" ]; then
if version_greater "$image_version" "$installed_version"; then
@ -213,6 +221,7 @@ if ! [ -f "/mnt/ncdata/skip.update" ]; then
#upgrade
else
touch "/mnt/ncdata/update.failed"
while [ -n "$(pgrep -f cron.php)" ]
do
echo "Waiting for Nextclouds cronjob to finish..."
@ -226,6 +235,7 @@ if ! [ -f "/mnt/ncdata/skip.update" ]; then
exit 1
fi
rm "/mnt/ncdata/update.failed"
bash /notify.sh "Nextcloud update to $image_version successful!" "Feel free to inspect the Nextcloud container logs for more info."
php /var/www/html/occ app:list | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_after