add a more generous solution to starting containers while backup still running

Signed-off-by: Simon L <szaimen@e.mail.de>
This commit is contained in:
Simon L 2023-02-19 23:21:04 +01:00
parent 7058cf2090
commit 491693f402
5 changed files with 15 additions and 36 deletions

View file

@ -11,10 +11,5 @@ RUN set -ex; \
; \
rm -rf /var/lib/apt/lists/*
COPY start.sh /
RUN chmod +x /start.sh
ENTRYPOINT ["/bin/tini", "--", "/start.sh"]
HEALTHCHECK CMD nc -z localhost 9200 || exit 1
LABEL com.centurylinklabs.watchtower.monitor-only="true"

View file

@ -1,18 +0,0 @@
#!/bin/bash
# Only start container if database is accessible (needed for backup to work correctly)
while ! nc -z "$POSTGRES_HOST" 5432; do
echo "Waiting for database to start..."
sleep 5
done
# Show wiki if vm.max_map_count is too low
if [ "$(sysctl -n vm.max_map_count)" -le 65530 ]; then
echo "max_map_count is too low and needs to be adjusted."
echo "See https://github.com/nextcloud/all-in-one/discussions/1775 how to change max_map_count"
fi
# Run initial entrypoint
/usr/local/bin/docker-entrypoint.sh
exec "$@"

View file

@ -38,9 +38,10 @@ if [ "$AUTOMATIC_UPDATES" = 1 ]; then
fi
# Wait for watchtower to stop
if [ "$AUTOMATIC_UPDATES" = 1 ] && ! docker ps --format "{{.Names}}" | grep -q "^nextcloud-aio-watchtower$"; then
echo "Something seems to be wrong: Watchtower should be started at this step."
else
if [ "$AUTOMATIC_UPDATES" = 1 ]; then
if ! docker ps --format "{{.Names}}" | grep -q "^nextcloud-aio-watchtower$"; then
echo "Something seems to be wrong: Watchtower should be started at this step."
fi
while docker ps --format "{{.Names}}" | grep -q "^nextcloud-aio-watchtower$"; do
echo "Waiting for watchtower to stop"
sleep 30
@ -58,6 +59,13 @@ fi
if [ "$DAILY_BACKUP" = 1 ]; then
echo "Creating daily backup..."
sudo -u www-data php /var/www/docker-aio/php/src/Cron/CreateBackup.php
if ! docker ps --format "{{.Names}}" | grep -q "^nextcloud-aio-borgbackup$"; then
echo "Something seems to be wrong: the borg container should be started at this step."
fi
while docker ps --format "{{.Names}}" | grep -q "^nextcloud-aio-borgbackup$"; do
echo "Waiting for backup container to stop"
sleep 30
done
fi
# Execute backup check

View file

@ -24,14 +24,10 @@
{% set isAnyRunning = false %}
{% set isAnyRestarting = false %}
{% set isWatchtowerRunning = false %}
{% set isRestoreRunning = false %}
{% set isBackupOrRestoreRunning = false %}
{% set isApacheStarting = false %}
{% if is_backup_container_running == true %}
{% if borg_backup_mode == 'restore' %}
{% set isRestoreRunning = true %}
{% endif %}
{% if borg_backup_mode == 'backup' or borg_backup_mode == 'restore' %}
{% set isBackupOrRestoreRunning = true %}
{% endif %}
@ -249,7 +245,7 @@
{% if has_update_available == true %}
{% if is_mastercontainer_update_available == false %}
⚠️ Container updates are available. Click on 'Stop Containers' and 'Start Containers' to update them. You should consider creating a backup first.<br><br>
⚠️ Container updates are available. Click on <b>Stop Containers</b> and <b>Start Containers</b> to update them. You should consider creating a backup first.<br><br>
{% endif %}
{% else %}
{% if is_mastercontainer_update_available == false %}
@ -277,10 +273,8 @@
</form>
{% endif %}
{% else %}
{% if isRestoreRunning == true %}
Restore currently running. Cannot start the containers until that's done.<br /><br />
{% elseif has_update_available == true and isBackupOrRestoreRunning == true %}
Restore or Backup currently running and container update available. Cannot start the containers until that's done.<br /><br />
{% if isBackupOrRestoreRunning == true %}
Restore or Backup currently running. Cannot start the containers until that's done.<br /><br />
{% else %}
{% if was_start_button_clicked == false %}
Clicking on the button below will download all docker containers and start them. This can take a lot of time depending on your internect connection. Since the overall size is a few GB, this will take around 5-10 min or more. So be aware and patient!<br><br>

View file

@ -420,7 +420,7 @@ Afterwards apply the correct permissions with `sudo chown root:root /root/backup
### How to stop/start/update containers or trigger the daily backup from a script externally?
You can do so by running the `/daily-backup.sh` script that is stored in the mastercontainer. It accepts the following environmental varilables:
- `AUTOMATIC_UPDATES` if set to `1`, it will automatically stop the containers, update them and start them including the mastercontainer. If the mastercontainer gets updated, this script's execution will stop as soon as the mastercontainer gets stopped. You can then wait until it is started again and run the script with this flag again in order to update all containers correctly afterwards.
- `DAILY_BACKUP` if set to `1`, it will automatically stop the containers and create a backup. If you want to start them again afterwards, you may have a look at the `START_CONTAINERS` option. Please be aware that this option is non-blocking if `START_CONTAINERS` and `AUTOMATIC_UPDATES` is not enabled at the same time which means that the backup check is not done when the process is finished since it only start the borgbackup container with the correct configuration.
- `DAILY_BACKUP` if set to `1`, it will automatically stop the containers and create a backup. If you want to start them again afterwards, you may have a look at the `START_CONTAINERS` option.
- `START_CONTAINERS` if set to `1`, it will automatically start the containers without updating them.
- `STOP_CONTAINERS` if set to `1`, it will automatically stop the containers.
- `CHECK_BACKUP` if set to `1`, it will start the backup check. This is not allowed to be enabled at the same time like `DAILY_BACKUP`. Please be aware that this option is non-blocking which means that the backup check is not done when the process is finished since it only start the borgbackup container with the correct configuration.