Synchronize repository with Athena deployment
This commit is contained in:
+16
-4
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
# Restore Athena's non-reproducible Docker state from the latest /data backup.
|
||||
# Restore Athena's configuration, deployed source and non-reproducible Docker
|
||||
# state from a local quick-recovery archive.
|
||||
set -Eeuo pipefail
|
||||
umask 077
|
||||
|
||||
@@ -60,7 +61,7 @@ backup_root=$work/backup
|
||||
[[ -d $backup_root/volumes ]] || die "Backup enthält keine Docker-Volumes."
|
||||
|
||||
# Stop only users of the restored volumes. WireGuard, SSH and networking stay up.
|
||||
for container in mike-ai-router mike-ai-profile-controller mike-ai-piper mike-ai-portainer; do
|
||||
for container in mike-ai-router mike-ai-profile-controller mike-ai-portainer; do
|
||||
if [[ $(docker inspect -f '{{.State.Running}}' "$container" 2>/dev/null || true) == true ]]; then
|
||||
docker stop "$container" >/dev/null
|
||||
fi
|
||||
@@ -69,6 +70,16 @@ done
|
||||
install -d -m 0700 /etc/mike-ai
|
||||
rsync -a --delete "$backup_root/etc-mike-ai/" /etc/mike-ai/
|
||||
|
||||
# New archives contain all deployed projects. Accept the old stack-only layout
|
||||
# as well so every already existing backup stays usable.
|
||||
if [[ -d $backup_root/opt-mike-ai ]]; then
|
||||
install -d -m 0755 /opt/mike-ai
|
||||
rsync -a "$backup_root/opt-mike-ai/" /opt/mike-ai/
|
||||
elif [[ -d $backup_root/stack ]]; then
|
||||
install -d -m 0755 /opt/mike-ai/stack
|
||||
rsync -a "$backup_root/stack/" /opt/mike-ai/stack/
|
||||
fi
|
||||
|
||||
restore_volume() {
|
||||
local volume=$1 source=$2 mountpoint
|
||||
[[ -d $source ]] || return 0
|
||||
@@ -78,12 +89,13 @@ restore_volume() {
|
||||
rsync -a --delete "$source/" "$mountpoint/"
|
||||
}
|
||||
|
||||
restore_volume mike-ai_piper-data "$backup_root/volumes/piper-data"
|
||||
restore_volume mike-ai_router-state "$backup_root/volumes/router-state"
|
||||
restore_volume mike-ai_router-images "$backup_root/volumes/router-images"
|
||||
restore_volume portainer_data "$backup_root/volumes/portainer-data"
|
||||
|
||||
cd "$ROOT_DIR"
|
||||
deploy_root=/opt/mike-ai/stack
|
||||
[[ -x $deploy_root/manage.sh ]] || deploy_root=$ROOT_DIR
|
||||
cd "$deploy_root"
|
||||
./manage.sh deploy core
|
||||
|
||||
printf 'ATHENA_RESTORE_OK %s\n' "$ARCHIVE"
|
||||
|
||||
Reference in New Issue
Block a user