skip any update procedure if nextcloud was just restored and more

Signed-off-by: szaimen <szaimen@e.mail.de>
This commit is contained in:
szaimen 2021-12-07 18:45:52 +01:00
parent c203ad65ef
commit 2ab0480f59
4 changed files with 190 additions and 156 deletions

View file

@ -83,6 +83,13 @@ if [ "$BORG_MODE" = backup ]; then
fi fi
done done
if [ -f "/nextcloud_aio_volumes/nextcloud_aio_database_dump/export.failed" ]; then
echo "Database export failed the last time. Most likely was the export time not high enough."
echo "Cannot create a backup now."
echo "Please report this to https://github.com/nextcloud/all-in-one/issues. Thanks!"
exit 1
fi
# Create backup folder # Create backup folder
mkdir -p "$BORG_BACKUP_DIRECTORY" mkdir -p "$BORG_BACKUP_DIRECTORY"
@ -140,6 +147,9 @@ if [ "$BORG_MODE" = backup ]; then
exit 1 exit 1
fi fi
# Remove the update skip file because the backup was successful
rm -f "/nextcloud_aio_volumes/nextcloud_aio_nextcloud_data/skip.update"
echo "$CURRENT_DATE,$CURRENT_DATE_READABLE" >> "/nextcloud_aio_volumes/nextcloud_aio_mastercontainer/data/backup_archives.list" echo "$CURRENT_DATE,$CURRENT_DATE_READABLE" >> "/nextcloud_aio_volumes/nextcloud_aio_mastercontainer/data/backup_archives.list"
chmod +r "/nextcloud_aio_volumes/nextcloud_aio_mastercontainer/data/backup_archives.list" chmod +r "/nextcloud_aio_volumes/nextcloud_aio_mastercontainer/data/backup_archives.list"
@ -187,6 +197,11 @@ if [ "$BORG_MODE" = restore ]; then
# Inform user # Inform user
get_expiration_time get_expiration_time
echo "Restore finished successfully on $END_DATE_READABLE ($DURATION_READABLE)" echo "Restore finished successfully on $END_DATE_READABLE ($DURATION_READABLE)"
# Add file to Nextcloud container so that it skips any update the next time
touch "/nextcloud_aio_volumes/nextcloud_aio_nextcloud_data/skip.update"
chmod 777 "/nextcloud_aio_volumes/nextcloud_aio_nextcloud_data/skip.update"
exit 0 exit 0
fi fi

View file

@ -25,6 +25,11 @@ fi
rm -f "/nextcloud_aio_volumes/nextcloud_aio_database_dump/backup-is-running" rm -f "/nextcloud_aio_volumes/nextcloud_aio_database_dump/backup-is-running"
if [ -n "$FAILED" ]; then if [ -n "$FAILED" ]; then
if [ "$BORG_MODE" = backup ]; then
# Add file to Nextcloud container so that it skips any update the next time
touch "/nextcloud_aio_volumes/nextcloud_aio_nextcloud_data/skip.update"
chmod 777 "/nextcloud_aio_volumes/nextcloud_aio_nextcloud_data/skip.update"
fi
exit 1 exit 1
fi fi

View file

@ -39,8 +39,9 @@ if [ "$installed_version" != "0.0.0.0" ]; then
unset ADMIN_PASSWORD unset ADMIN_PASSWORD
fi fi
# Skip any update if Nextcloud was just restored
if version_greater "$image_version" "$installed_version"; then if ! [ -f "/mnt/ncdata/skip.update" ]; then
if version_greater "$image_version" "$installed_version"; then
# Check if it skips a major version # Check if it skips a major version
INSTALLED_MAJOR="${installed_version%%.*}" INSTALLED_MAJOR="${installed_version%%.*}"
IMAGE_MAJOR="${image_version%%.*}" IMAGE_MAJOR="${image_version%%.*}"
@ -204,6 +205,7 @@ if version_greater "$image_version" "$installed_version"; then
php /var/www/html/occ maintenance:mimetype:update-js php /var/www/html/occ maintenance:mimetype:update-js
php /var/www/html/occ maintenance:mimetype:update-db php /var/www/html/occ maintenance:mimetype:update-db
fi fi
fi
fi fi
# Apply one-click-instance settings # Apply one-click-instance settings
@ -260,3 +262,6 @@ SIGNALING_SERVERS="{\"servers\":[{\"server\":\"https://$NC_DOMAIN/standalone-sig
php /var/www/html/occ config:app:set spreed stun_servers --value="$STUN_SERVERS" --output json php /var/www/html/occ config:app:set spreed stun_servers --value="$STUN_SERVERS" --output json
php /var/www/html/occ config:app:set spreed turn_servers --value="$TURN_SERVERS" --output json php /var/www/html/occ config:app:set spreed turn_servers --value="$TURN_SERVERS" --output json
php /var/www/html/occ config:app:set spreed signaling_servers --value="$SIGNALING_SERVERS" --output json php /var/www/html/occ config:app:set spreed signaling_servers --value="$SIGNALING_SERVERS" --output json
# Remove the update skip file always
rm -f /mnt/ncdata/skip.update

View file

@ -27,6 +27,13 @@ if ( [ -f "$DATADIR/PG_VERSION" ] && [ "$PG_MAJOR" != "$(cat "$DATADIR/PG_VERSIO
exit 1 exit 1
fi fi
# If database export was unsuccessful, skip update
if [ -f "$DUMP_DIR/export.failed" ]; then
echo "Database export failed the last time. Most likely was the export time not high enough."
echo "Plese report this to https://github.com/nextcloud/all-in-one/issues. Thanks!"
exit 1
fi
# Inform # Inform
echo "Restoring from database dump." echo "Restoring from database dump."
@ -74,10 +81,12 @@ wait $!
# Continue with shutdown procedure: do database dump, etc. # Continue with shutdown procedure: do database dump, etc.
rm -f "$DUMP_FILE.temp" rm -f "$DUMP_FILE.temp"
touch "$DUMP_DIR/export.failed"
if pg_dump --username "$POSTGRES_USER" "$POSTGRES_DB" > "$DUMP_FILE.temp"; then if pg_dump --username "$POSTGRES_USER" "$POSTGRES_DB" > "$DUMP_FILE.temp"; then
rm -f "$DUMP_FILE" rm -f "$DUMP_FILE"
mv "$DUMP_FILE.temp" "$DUMP_FILE" mv "$DUMP_FILE.temp" "$DUMP_FILE"
pg_ctl stop -m fast pg_ctl stop -m fast
rm "$DUMP_DIR/export.failed"
echo 'Database dump successful!' echo 'Database dump successful!'
exit 0 exit 0
else else