improve the script

Signed-off-by: Simon L <szaimen@e.mail.de>
This commit is contained in:
Simon L 2022-11-20 00:59:40 +01:00
parent d5272c0ea7
commit e323f9770b

View file

@ -549,6 +549,7 @@ But anyhow, is here a guide that helps you automate the whole procedure:
```bash
#!/bin/bash
# Stop the containers
docker exec -e STOP_CONTAINERS=1 nextcloud-aio-mastercontainer /daily-backup.sh
# Below is optional if you run AIO in a VM which will shut down the VM afterwards
@ -566,7 +567,7 @@ Afterwards apply the correct permissions with `sudo chown root:root /root/shutdo
1. save and close the crontab (when using nano are the shortcuts for this `Ctrl + o` -> `Enter` and close the editor with `Ctrl + x`).
**After that is in place, you should schedule a backup from your backup solution that creates a backup after AIO is shut down properly.**
**After that is in place, you should schedule a backup from your backup solution that creates a backup after AIO is shut down properly. Hint: If your backup runs on the same host, make sure to at least back up all docker volumes and additionally Nextclouds datadir, if it is not stored in a docker volume.**
**Afterwards, you can create a second script that automatically updates the containers:**
@ -576,36 +577,27 @@ Afterwards apply the correct permissions with `sudo chown root:root /root/shutdo
```bash
#!/bin/bash
# Please modify all variables below to your needings:
APACHE_PORT="443" # This needs to match the chosen APACHE_PORT port of AIO, e.g. 11000. By default it is 443.
########################################
# Please do NOT modify anything below! #
########################################
# Run container update once
docker exec -e AUTOMATIC_UPDATES=1 nextcloud-aio-mastercontainer /daily-backup.sh
if ! docker exec -e AUTOMATIC_UPDATES=1 nextcloud-aio-mastercontainer /daily-backup.sh; then
while docker ps --format "{{.Names}}" | grep -q "^nextcloud-aio-watchtower$"; do
echo "Waiting for watchtower to stop"
sleep 30
done
# Wait until Watchtower is finished
while docker ps --format "{{.Names}}" | grep -q "^nextcloud-aio-watchtower$"; do
echo "Waiting for watchtower to stop"
sleep 30
done
while ! docker ps --format "{{.Names}}" | grep -q "^nextcloud-aio-mastercontainer$"; do
echo "Waiting for Mastercontainer to start"
sleep 30
done
# Wait until Apache is running again
while nc -z localhost "$APACHE_PORT"; do
echo "Waiting for Apache to start"
sleep 30
done
# Run container update another time to make sure that all containers are updated correctly.
docker exec -e AUTOMATIC_UPDATES=1 nextcloud-aio-mastercontainer /daily-backup.sh
# Run container update another time to make sure that all containers are updated correctly.
docker exec -e AUTOMATIC_UPDATES=1 nextcloud-aio-mastercontainer /daily-backup.sh
fi
```
</details>
You can simply copy and past the script into a file e.g. named `automatic-updates.sh` e.g. here: `/root/automatic-updates.sh`. Do not forget to modify the variables to your requirements!
You can simply copy and past the script into a file e.g. named `automatic-updates.sh` e.g. here: `/root/automatic-updates.sh`.
Afterwards apply the correct permissions with `sudo chown root:root /root/automatic-updates.sh` and `sudo chmod 700 /root/automatic-updates.sh`. Then you can create a cronjob that runs e.g. at `05:00` each day like this:
1. Open the cronjob with `sudo crontab -u root -e` (and choose your editor of choice if not already done. I'd recommend nano).