Backup automatico script del 2026-07-26 07:00
This commit is contained in:
1 parent
4802b021fe
commit
a9bbb92090
19 files changed
+1086
-550
No files matched your search
@@ -45,12 +45,21 @@ done
|
||||
case "$(hostname -s)" in
|
||||
pi1)
|
||||
HOST_LABEL="Pi-1 (Master)"
|
||||
# Immagini build locali (no registry pubblico) → escluse da Watchtower
|
||||
DOCKER_IGNORE_IMAGES=("turni-app:live-latest")
|
||||
;;
|
||||
pi2)
|
||||
HOST_LABEL="Pi-2 (Backup)"
|
||||
CHECK_PIP3=true
|
||||
DOCKER_IGNORE_IMAGES=("irrigazione:latest" "turni-app:beta-latest" "turni-app:alpha-latest")
|
||||
# Immagini build locali (no registry pubblico) → escluse da Watchtower
|
||||
DOCKER_IGNORE_IMAGES=(
|
||||
"irrigazione:latest"
|
||||
"turni-app:beta-latest"
|
||||
"turni-app:alpha-latest"
|
||||
"meteo-alert:latest"
|
||||
"loogle-casa:latest"
|
||||
"ewelink_smart_home:1.4.6"
|
||||
)
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -143,34 +152,52 @@ image_is_ignored() {
|
||||
return 1
|
||||
}
|
||||
|
||||
ensure_watchtower_labels() {
|
||||
command -v docker >/dev/null 2>&1 || return 0
|
||||
local name image
|
||||
# Elenco nomi container da escludere (immagini locali / no registry).
|
||||
# Nota: `docker update --label-add` non esiste → usiamo WATCHTOWER_DISABLE_CONTAINERS.
|
||||
watchtower_disabled_containers() {
|
||||
local name image disabled=()
|
||||
while IFS= read -r line; do
|
||||
[[ -z "$line" ]] && continue
|
||||
name=${line%%|*}
|
||||
image=${line#*|}
|
||||
image_is_ignored "$image" || continue
|
||||
docker update --label-add com.centurylinklabs.watchtower.enable=false "$name" >/dev/null 2>&1 || true
|
||||
done < <(docker ps --format '{{.Names}}|{{.Image}}' 2>/dev/null || true)
|
||||
if image_is_ignored "$image"; then
|
||||
disabled+=("$name")
|
||||
fi
|
||||
done < <(docker ps -a --format '{{.Names}}|{{.Image}}' 2>/dev/null || true)
|
||||
if ((${#disabled[@]} > 0)); then
|
||||
local IFS=,
|
||||
printf '%s' "${disabled[*]}"
|
||||
fi
|
||||
}
|
||||
|
||||
run_watchtower() {
|
||||
command -v docker >/dev/null 2>&1 || return 0
|
||||
|
||||
ensure_watchtower_labels
|
||||
local disable_list
|
||||
disable_list=$(watchtower_disabled_containers)
|
||||
|
||||
log "▶ Watchtower (run-once, container aggiornabili da registry)"
|
||||
append_report ""
|
||||
append_report "=== Watchtower run-once ==="
|
||||
if [[ -n "$disable_list" ]]; then
|
||||
log "Watchtower: esclusi container locali: $disable_list"
|
||||
append_report "Esclusi (immagini locali): $disable_list"
|
||||
fi
|
||||
|
||||
local -a env_args=(
|
||||
-e WATCHTOWER_CLEANUP=true
|
||||
-e WATCHTOWER_ROLLING_RESTART=false
|
||||
-e "WATCHTOWER_TIMEOUT=${WATCHTOWER_TIMEOUT}"
|
||||
-e TZ=Europe/Rome
|
||||
)
|
||||
if [[ -n "$disable_list" ]]; then
|
||||
env_args+=(-e "WATCHTOWER_DISABLE_CONTAINERS=${disable_list}")
|
||||
fi
|
||||
|
||||
local output rc=0
|
||||
output=$(docker run --rm \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||
-e WATCHTOWER_CLEANUP=true \
|
||||
-e WATCHTOWER_ROLLING_RESTART=false \
|
||||
-e WATCHTOWER_TIMEOUT="${WATCHTOWER_TIMEOUT}" \
|
||||
-e TZ=Europe/Rome \
|
||||
"${env_args[@]}" \
|
||||
"$WATCHTOWER_IMAGE" \
|
||||
--run-once 2>&1) || rc=$?
|
||||
|
||||
|
||||
Reference in new issue
Block a user