From 1b195cbd1c6ab349ec9cb13a5237a9bd7184a617 Mon Sep 17 00:00:00 2001 From: MickLesk Date: Fri, 19 Jun 2026 23:42:12 +0200 Subject: [PATCH] refactor(ct): migrate manual update backups to create_backup (batch 2) Manually standardize 52 more update scripts with clear backup/restore patterns, including multi-path and post-build restore timing where needed. Co-authored-by: Cursor --- ct/alpine-cinny.sh | 10 ++-------- ct/alpine-garage.sh | 6 ++---- ct/alpine-ironclaw.sh | 10 ++-------- ct/endurain.sh | 12 ++++-------- ct/fladder.sh | 15 ++------------- ct/garage.sh | 6 ++---- ct/gatus.sh | 5 +++-- ct/grist.sh | 12 ++---------- ct/guardian.sh | 16 ++-------------- ct/homer.sh | 13 ++----------- ct/hoodik.sh | 10 ++-------- ct/igotify.sh | 10 ++-------- ct/investbrain.sh | 12 ++---------- ct/ironclaw.sh | 10 ++-------- ct/kan.sh | 10 ++-------- ct/kapowarr.sh | 6 ++---- ct/kima-hub.sh | 12 ++---------- ct/kitchenowl.sh | 15 +++------------ ct/librechat.sh | 18 ++++-------------- ct/lobehub.sh | 10 ++-------- ct/metabase.sh | 9 ++------- ct/monica.sh | 8 ++------ ct/neko.sh | 9 ++------- ct/netboot-xyz.sh | 9 ++------- ct/nginx-ui.sh | 9 ++------- ct/ombi.sh | 12 ++---------- ct/opengist.sh | 9 ++------- ct/outline.sh | 6 ++---- ct/overseerr.sh | 7 ++----- ct/paperclip.sh | 9 ++------- ct/papra.sh | 12 +++--------- ct/powerdns.sh | 9 ++------- ct/prometheus-blackbox-exporter.sh | 10 ++-------- ct/reactive-resume.sh | 5 +++-- ct/romm.sh | 6 ++---- ct/rustypaste.sh | 12 ++---------- ct/seerr.sh | 9 ++------- ct/slskd.sh | 20 +++++--------------- ct/speedtest-tracker.sh | 6 ++---- ct/spliit.sh | 10 ++-------- ct/storyteller.sh | 9 ++------- ct/teable.sh | 9 ++------- ct/teddycloud.sh | 10 ++-------- ct/traccar.sh | 12 ++---------- ct/tubearchivist.sh | 7 ++----- ct/wallabag.sh | 10 ++-------- ct/wallos.sh | 9 ++------- ct/wavelog.sh | 21 +++++---------------- ct/writefreely.sh | 13 ++----------- ct/yamtrack.sh | 9 ++------- ct/zerobyte.sh | 11 +++-------- ct/zigbee2mqtt.sh | 6 ++---- 52 files changed, 119 insertions(+), 411 deletions(-) diff --git a/ct/alpine-cinny.sh b/ct/alpine-cinny.sh index 72c93f3e6..f489f4a8b 100644 --- a/ct/alpine-cinny.sh +++ b/ct/alpine-cinny.sh @@ -30,16 +30,10 @@ function update_script() { fi if check_for_gh_release "cinny" "cinnyapp/cinny"; then - msg_info "Backing up Configuration" - cp /opt/cinny/config.json /opt/cinny_config.json.bak - msg_ok "Backed up Configuration" + create_backup /opt/cinny/config.json CLEAN_INSTALL=1 fetch_and_deploy_gh_release "cinny" "cinnyapp/cinny" "prebuild" "latest" "/opt/cinny" "cinny-*.tar.gz" - - msg_info "Restoring Configuration" - cp /opt/cinny_config.json.bak /opt/cinny/config.json - rm -f /opt/cinny_config.json.bak - msg_ok "Restored Configuration" + restore_backup msg_info "Restarting nginx" $STD rc-service nginx restart diff --git a/ct/alpine-garage.sh b/ct/alpine-garage.sh index a132e9248..bafce28e3 100644 --- a/ct/alpine-garage.sh +++ b/ct/alpine-garage.sh @@ -33,15 +33,13 @@ function update_script() { rc-service garage stop || true msg_ok "Stopped Service" - msg_info "Backing Up Data" - cp /usr/local/bin/garage /usr/local/bin/garage.old 2>/dev/null || true - cp /etc/garage.toml /etc/garage.toml.bak 2>/dev/null || true - msg_ok "Backed Up Data" + create_backup /etc/garage.toml msg_info "Updating Garage" curl -fsSL "https://garagehq.deuxfleurs.fr/_releases/${GITEA_RELEASE}/$(arch_resolve "x86_64" "aarch64")-unknown-linux-musl/garage" -o /usr/local/bin/garage chmod +x /usr/local/bin/garage echo "${GITEA_RELEASE}" >~/.garage + clear_update_backup msg_ok "Updated Garage" msg_info "Starting Service" diff --git a/ct/alpine-ironclaw.sh b/ct/alpine-ironclaw.sh index f21e59a61..b26fe8f63 100644 --- a/ct/alpine-ironclaw.sh +++ b/ct/alpine-ironclaw.sh @@ -33,18 +33,12 @@ function update_script() { rc-service ironclaw stop 2>/dev/null || true msg_ok "Stopped Service" - msg_info "Backing up Configuration" - cp /root/.ironclaw/.env /root/ironclaw.env.bak - msg_ok "Backed up Configuration" + create_backup /root/.ironclaw/.env fetch_and_deploy_gh_release "ironclaw-bin" "nearai/ironclaw" "prebuild" "latest" "/usr/local/bin" \ "ironclaw-$(uname -m)-unknown-linux-musl.tar.gz" chmod +x /usr/local/bin/ironclaw - - msg_info "Restoring Configuration" - cp /root/ironclaw.env.bak /root/.ironclaw/.env - rm -f /root/ironclaw.env.bak - msg_ok "Restored Configuration" + restore_backup msg_info "Starting Service" rc-service ironclaw start diff --git a/ct/endurain.sh b/ct/endurain.sh index 664efe62a..e884bc930 100644 --- a/ct/endurain.sh +++ b/ct/endurain.sh @@ -34,10 +34,8 @@ function update_script() { systemctl stop endurain msg_ok "Stopped Service" - msg_info "Creating Backup" - cp /opt/endurain/.env /opt/endurain.env - cp /opt/endurain/frontend/app/dist/env.js /opt/endurain.env.js - msg_ok "Created Backup" + create_backup /opt/endurain/.env + [[ -f /opt/endurain/frontend/app/dist/env.js ]] && cp /opt/endurain/frontend/app/dist/env.js /opt/endurain.env.js CLEAN_INSTALL=1 fetch_and_deploy_codeberg_release "endurain" "endurain-project/endurain" "tarball" "latest" "/opt/endurain" @@ -47,16 +45,14 @@ function update_script() { /opt/endurain/{docs,example.env,screenshot_01.png} \ /opt/endurain/docker* \ /opt/endurain/*.yml - cp /opt/endurain.env /opt/endurain/.env - rm /opt/endurain.env + restore_backup msg_ok "Prepared Update" msg_info "Updating Frontend" cd /opt/endurain/frontend/app $STD npm ci $STD npm run build - cp /opt/endurain.env.js /opt/endurain/frontend/app/dist/env.js - rm /opt/endurain.env.js + [[ -f /opt/endurain.env.js ]] && cp /opt/endurain.env.js /opt/endurain/frontend/app/dist/env.js && rm -f /opt/endurain.env.js msg_ok "Updated Frontend" msg_info "Updating Backend" diff --git a/ct/fladder.sh b/ct/fladder.sh index 4a7d4ca3d..292ccb93d 100644 --- a/ct/fladder.sh +++ b/ct/fladder.sh @@ -35,21 +35,10 @@ function update_script() { systemctl stop nginx msg_ok "Stopped Service" - if [[ -f /opt/fladder/assets/config/config.json ]]; then - msg_info "Backing up configuration" - cp /opt/fladder/assets/config/config.json /tmp/fladder_config.json.bak - msg_ok "Configuration backed up" - fi + create_backup /opt/fladder/assets/config/config.json CLEAN_INSTALL=1 fetch_and_deploy_gh_release "Fladder" "DonutWare/Fladder" "prebuild" "latest" "/opt/fladder" "Fladder-Web-*.zip" - - if [[ -f /tmp/fladder_config.json.bak ]]; then - msg_info "Restoring configuration" - mkdir -p /opt/fladder/assets/config - cp /tmp/fladder_config.json.bak /opt/fladder/assets/config/config.json - rm -f /tmp/fladder_config.json.bak - msg_ok "Configuration restored" - fi + restore_backup msg_info "Starting Service" systemctl start nginx diff --git a/ct/garage.sh b/ct/garage.sh index fefc96926..9fa6bce75 100644 --- a/ct/garage.sh +++ b/ct/garage.sh @@ -34,15 +34,13 @@ function update_script() { systemctl stop garage msg_ok "Stopped Service" - msg_info "Backing Up Data" - cp /usr/local/bin/garage /usr/local/bin/garage.old 2>/dev/null || true - cp /etc/garage.toml /etc/garage.toml.bak 2>/dev/null || true - msg_ok "Backed Up Data" + create_backup /etc/garage.toml msg_info "Updating Garage" curl -fsSL "https://garagehq.deuxfleurs.fr/_releases/${GITEA_RELEASE}/x86_64-unknown-linux-musl/garage" -o /usr/local/bin/garage chmod +x /usr/local/bin/garage echo "${GITEA_RELEASE}" >~/.garage + clear_update_backup msg_ok "Updated Garage" msg_info "Starting Service" diff --git a/ct/gatus.sh b/ct/gatus.sh index 726bcb652..bdab1d8e0 100644 --- a/ct/gatus.sh +++ b/ct/gatus.sh @@ -34,15 +34,16 @@ function update_script() { systemctl stop gatus msg_ok "Stopped Service" - mv /opt/gatus/config/config.yaml /opt + create_backup /opt/gatus/config/config.yaml + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "gatus" "TwiN/gatus" "tarball" + restore_backup msg_info "Updating Gatus" cd /opt/gatus $STD go mod tidy CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o gatus . setcap CAP_NET_RAW+ep gatus - mv /opt/config.yaml config msg_ok "Updated Gatus" msg_info "Starting Service" diff --git a/ct/grist.sh b/ct/grist.sh index 832f58717..5a10b618d 100644 --- a/ct/grist.sh +++ b/ct/grist.sh @@ -37,21 +37,13 @@ function update_script() { systemctl stop grist msg_ok "Stopped Service" - msg_info "Creating backup" - rm -rf /opt/grist_bak - mv /opt/grist /opt/grist_bak - msg_ok "Backup created" + create_backup /opt/grist/.env /opt/grist/docs /opt/grist/grist-sessions.db /opt/grist/landing.db fetch_and_deploy_gh_release "grist" "gristlabs/grist-core" "tarball" + restore_backup msg_info "Updating Grist" mkdir -p /opt/grist/docs - cp -n /opt/grist_bak/.env /opt/grist/.env - if ls /opt/grist_bak/docs/* &>/dev/null; then - cp -r /opt/grist_bak/docs/* /opt/grist/docs/ - fi - [[ -f /opt/grist_bak/grist-sessions.db ]] && cp /opt/grist_bak/grist-sessions.db /opt/grist/grist-sessions.db - [[ -f /opt/grist_bak/landing.db ]] && cp /opt/grist_bak/landing.db /opt/grist/landing.db cd /opt/grist $STD yarn install $STD yarn run build:prod diff --git a/ct/guardian.sh b/ct/guardian.sh index 51a8ffc9e..55670539b 100755 --- a/ct/guardian.sh +++ b/ct/guardian.sh @@ -35,22 +35,10 @@ function update_script() { systemctl stop guardian-backend guardian-frontend msg_ok "Stopped Services" - if [[ -f "/opt/guardian/backend/plex-guard.db" ]]; then - msg_info "Backing up Database" - cp "/opt/guardian/backend/plex-guard.db" "/tmp/plex-guard.db.backup" - msg_ok "Backed up Database" - fi + create_backup /opt/guardian/.env /opt/guardian/backend/plex-guard.db - [[ -f "/opt/guardian/.env" ]] && cp "/opt/guardian/.env" "/opt" CLEAN_INSTALL=1 fetch_and_deploy_gh_release "guardian" "HydroshieldMKII/Guardian" "tarball" "latest" "/opt/guardian" - [[ -f "/opt/.env" ]] && mv "/opt/.env" "/opt/guardian" - - if [[ -f "/tmp/plex-guard.db.backup" ]]; then - msg_info "Restoring Database" - cp "/tmp/plex-guard.db.backup" "/opt/guardian/backend/plex-guard.db" - rm "/tmp/plex-guard.db.backup" - msg_ok "Restored Database" - fi + restore_backup msg_info "Updating Guardian" cd /opt/guardian/backend diff --git a/ct/homer.sh b/ct/homer.sh index abd77c995..569e7bc58 100644 --- a/ct/homer.sh +++ b/ct/homer.sh @@ -34,19 +34,10 @@ function update_script() { systemctl stop homer msg_ok "Stopped Service" - msg_info "Backing up assets directory" - cd ~ - mkdir -p assets-backup - cp -R /opt/homer/assets/. assets-backup - msg_ok "Backed up assets directory" + create_backup /opt/homer/assets CLEAN_INSTALL=1 fetch_and_deploy_gh_release "homer" "bastienwirtz/homer" "prebuild" "latest" "/opt/homer" "homer.zip" - - msg_info "Restoring assets directory" - cd ~ - cp -Rf assets-backup/. /opt/homer/assets/ - rm -rf assets-backup - msg_ok "Restored assets directory" + restore_backup msg_info "Starting Service" systemctl start homer diff --git a/ct/hoodik.sh b/ct/hoodik.sh index 7acd7a3d6..0b267fe6a 100644 --- a/ct/hoodik.sh +++ b/ct/hoodik.sh @@ -36,16 +36,10 @@ function update_script() { systemctl stop hoodik msg_ok "Stopped Service" - msg_info "Backing up Configuration" - cp /opt/hoodik/.env /opt/hoodik.env.bak - msg_ok "Backed up Configuration" + create_backup /opt/hoodik/.env CLEAN_INSTALL=1 fetch_and_deploy_gh_release "hoodik" "hudikhq/hoodik" "prebuild" "latest" "/opt/hoodik" "*x86_64.tar.gz" - - msg_info "Restoring Configuration" - cp /opt/hoodik.env.bak /opt/hoodik/.env - rm -f /opt/hoodik.env.bak - msg_ok "Restored Configuration" + restore_backup msg_info "Starting Service" systemctl start hoodik diff --git a/ct/igotify.sh b/ct/igotify.sh index 10b153966..a59723250 100644 --- a/ct/igotify.sh +++ b/ct/igotify.sh @@ -35,16 +35,10 @@ function update_script() { systemctl stop igotify msg_ok "Stopped Service" - msg_info "Backing up Configuration" - cp /opt/igotify/.env /opt/igotify.env.bak - msg_ok "Backed up Configuration" + create_backup /opt/igotify/.env CLEAN_INSTALL=1 fetch_and_deploy_gh_release "igotify" "androidseb25/iGotify-Notification-Assistent" "prebuild" "latest" "/opt/igotify" "iGotify-Notification-Service-amd64-v*.zip" - - msg_info "Restoring Configuration" - cp /opt/igotify.env.bak /opt/igotify/.env - rm -f /opt/igotify.env.bak - msg_ok "Restored Configuration" + restore_backup msg_info "Starting Service" systemctl start igotify diff --git a/ct/investbrain.sh b/ct/investbrain.sh index 3d619fc0f..cbeec7fc3 100644 --- a/ct/investbrain.sh +++ b/ct/investbrain.sh @@ -41,20 +41,13 @@ function update_script() { NODE_VERSION="22" setup_nodejs PG_VERSION="17" setup_postgresql - msg_info "Creating Backup" - rm -f /opt/.env.backup - rm -rf /opt/investbrain_backup - cp /opt/investbrain/.env /opt/.env.backup - cp -r /opt/investbrain/storage /opt/investbrain_backup - msg_ok "Created Backup" + create_backup /opt/investbrain/.env /opt/investbrain/storage fetch_and_deploy_gh_release "Investbrain" "investbrainapp/investbrain" "tarball" "latest" "/opt/investbrain" + restore_backup msg_info "Updating Investbrain" cd /opt/investbrain - rm -rf /opt/investbrain/storage - cp /opt/.env.backup /opt/investbrain/.env - cp -r /opt/investbrain_backup/ /opt/investbrain/storage export COMPOSER_ALLOW_SUPERUSER=1 $STD /usr/local/bin/composer install --no-interaction --no-dev --optimize-autoloader $STD npm install @@ -69,7 +62,6 @@ function update_script() { $STD php artisan event:cache chown -R www-data:www-data /opt/investbrain chmod -R 775 /opt/investbrain/storage /opt/investbrain/bootstrap/cache - rm -rf /opt/.env.backup /opt/investbrain_backup msg_ok "Updated Investbrain" msg_info "Starting Services" diff --git a/ct/ironclaw.sh b/ct/ironclaw.sh index b2e3eed28..9f6173935 100644 --- a/ct/ironclaw.sh +++ b/ct/ironclaw.sh @@ -35,18 +35,12 @@ function update_script() { systemctl stop ironclaw msg_ok "Stopped Service" - msg_info "Backing up Configuration" - cp /root/.ironclaw/.env /root/ironclaw.env.bak - msg_ok "Backed up Configuration" + create_backup /root/.ironclaw/.env fetch_and_deploy_gh_release "ironclaw-bin" "nearai/ironclaw" "prebuild" "latest" "/usr/local/bin" \ "ironclaw-$(uname -m)-unknown-linux-gnu.tar.gz" chmod +x /usr/local/bin/ironclaw - - msg_info "Restoring Configuration" - cp /root/ironclaw.env.bak /root/.ironclaw/.env - rm -f /root/ironclaw.env.bak - msg_ok "Restored Configuration" + restore_backup msg_info "Starting Service" systemctl start ironclaw diff --git a/ct/kan.sh b/ct/kan.sh index 221668159..09e44d0c0 100644 --- a/ct/kan.sh +++ b/ct/kan.sh @@ -35,16 +35,10 @@ function update_script() { systemctl stop kan msg_ok "Stopped Service" - msg_info "Backing up Data" - cp /opt/kan/.env /opt/kan.env.bak - msg_ok "Backed up Data" + create_backup /opt/kan/.env CLEAN_INSTALL=1 fetch_and_deploy_gh_tag "kan" "kanbn/kan" "latest" - - msg_info "Restoring Configuration" - cp /opt/kan.env.bak /opt/kan/.env - rm -f /opt/kan.env.bak - msg_ok "Restored Configuration" + restore_backup msg_info "Building Application" cd /opt/kan diff --git a/ct/kapowarr.sh b/ct/kapowarr.sh index 664f6832b..f22d29bea 100644 --- a/ct/kapowarr.sh +++ b/ct/kapowarr.sh @@ -37,14 +37,12 @@ function update_script() { systemctl stop kapowarr msg_ok "Stopped Service" - msg_info "Creating Backup" - mv /opt/kapowarr/db /opt/ - msg_ok "Backup Created" + create_backup /opt/kapowarr/db fetch_and_deploy_gh_release "kapowarr" "Casvt/Kapowarr" "tarball" + restore_backup msg_info "Updating Kapowarr" - mv /opt/db /opt/kapowarr msg_ok "Updated Kapowarr" msg_info "Starting Service" diff --git a/ct/kima-hub.sh b/ct/kima-hub.sh index d43eead41..c3ba99faa 100644 --- a/ct/kima-hub.sh +++ b/ct/kima-hub.sh @@ -37,18 +37,10 @@ function update_script() { systemctl stop kima-frontend kima-backend kima-analyzer kima-analyzer-clap msg_ok "Stopped Services" - msg_info "Backing up Data" - cp /opt/kima-hub/backend/.env /opt/kima-hub-backend-env.bak - cp /opt/kima-hub/frontend/.env /opt/kima-hub-frontend-env.bak - msg_ok "Backed up Data" + create_backup /opt/kima-hub/backend/.env /opt/kima-hub/frontend/.env CLEAN_INSTALL=1 fetch_and_deploy_gh_release "kima-hub" "Chevron7Locked/kima-hub" "tarball" - - msg_info "Restoring Data" - cp /opt/kima-hub-backend-env.bak /opt/kima-hub/backend/.env - cp /opt/kima-hub-frontend-env.bak /opt/kima-hub/frontend/.env - rm -f /opt/kima-hub-backend-env.bak /opt/kima-hub-frontend-env.bak - msg_ok "Restored Data" + restore_backup msg_info "Rebuilding Backend" cd /opt/kima-hub/backend diff --git a/ct/kitchenowl.sh b/ct/kitchenowl.sh index fcdda0438..27b75aea4 100644 --- a/ct/kitchenowl.sh +++ b/ct/kitchenowl.sh @@ -35,24 +35,15 @@ function update_script() { systemctl stop kitchenowl msg_ok "Stopped Service" - msg_info "Creating Backup" - mkdir -p /opt/kitchenowl_backup - cp -r /opt/kitchenowl/data /opt/kitchenowl_backup/ - cp -f /opt/kitchenowl/kitchenowl.env /opt/kitchenowl_backup/ - msg_ok "Created Backup" + create_backup /opt/kitchenowl/data /opt/kitchenowl/kitchenowl.env CLEAN_INSTALL=1 fetch_and_deploy_gh_release "kitchenowl" "TomBursch/kitchenowl" "tarball" "latest" "/opt/kitchenowl" rm -rf /opt/kitchenowl/web CLEAN_INSTALL=1 fetch_and_deploy_gh_release "kitchenowl-web" "TomBursch/kitchenowl" "prebuild" "latest" "/opt/kitchenowl/web" "kitchenowl_Web.tar.gz" - - msg_info "Restoring data" - sed -i 's/default=True/default=False/' /opt/kitchenowl/backend/wsgi.py - cp -r /opt/kitchenowl_backup/data /opt/kitchenowl/ - cp -f /opt/kitchenowl_backup/kitchenowl.env /opt/kitchenowl/ - rm -rf /opt/kitchenowl_backup - msg_ok "Restored data" + restore_backup msg_info "Updating KitchenOwl" + sed -i 's/default=True/default=False/' /opt/kitchenowl/backend/wsgi.py cd /opt/kitchenowl/backend $STD uv sync --frozen cd /opt/kitchenowl/backend diff --git a/ct/librechat.sh b/ct/librechat.sh index 5c60e0a52..8105366cd 100644 --- a/ct/librechat.sh +++ b/ct/librechat.sh @@ -35,9 +35,7 @@ function update_script() { systemctl stop librechat rag-api msg_ok "Stopped Services" - msg_info "Backing up Configuration" - cp /opt/librechat/.env /opt/librechat.env.bak - msg_ok "Backed up Configuration" + create_backup /opt/librechat/.env CLEAN_INSTALL=1 fetch_and_deploy_gh_tag "librechat" "danny-avila/LibreChat" @@ -52,10 +50,7 @@ function update_script() { $STD npm cache clean --force msg_ok "Built Frontend" - msg_info "Restoring Configuration" - cp /opt/librechat.env.bak /opt/librechat/.env - rm -f /opt/librechat.env.bak - msg_ok "Restored Configuration" + restore_backup msg_info "Starting Services" systemctl start rag-api librechat @@ -68,9 +63,7 @@ function update_script() { systemctl stop rag-api msg_ok "Stopped RAG API" - msg_info "Backing up RAG API Configuration" - cp /opt/rag-api/.env /opt/rag-api.env.bak - msg_ok "Backed up RAG API Configuration" + create_backup /opt/rag-api/.env CLEAN_INSTALL=1 fetch_and_deploy_gh_release "rag-api" "danny-avila/rag_api" "tarball" @@ -79,10 +72,7 @@ function update_script() { $STD .venv/bin/pip install -r requirements.lite.txt msg_ok "Updated RAG API Dependencies" - msg_info "Restoring RAG API Configuration" - cp /opt/rag-api.env.bak /opt/rag-api/.env - rm -f /opt/rag-api.env.bak - msg_ok "Restored RAG API Configuration" + restore_backup msg_info "Starting RAG API" systemctl start rag-api diff --git a/ct/lobehub.sh b/ct/lobehub.sh index d42912c1b..99e948a9f 100644 --- a/ct/lobehub.sh +++ b/ct/lobehub.sh @@ -35,16 +35,10 @@ function update_script() { systemctl stop lobehub msg_ok "Stopped Services" - msg_info "Backing up Data" - cp /opt/lobehub/.env /opt/lobehub.env.bak - msg_ok "Backed up Data" + create_backup /opt/lobehub/.env CLEAN_INSTALL=1 fetch_and_deploy_gh_release "lobehub" "lobehub/lobehub" "tarball" - - msg_info "Restoring Configuration" - cp /opt/lobehub.env.bak /opt/lobehub/.env - rm -f /opt/lobehub.env.bak - msg_ok "Restored Configuration" + restore_backup msg_info "Building Application" cd /opt/lobehub diff --git a/ct/metabase.sh b/ct/metabase.sh index 1b55456be..33e97d3d8 100644 --- a/ct/metabase.sh +++ b/ct/metabase.sh @@ -34,20 +34,15 @@ function update_script() { systemctl stop metabase msg_info "Stopped Service" - msg_info "Creating backup" - mv /opt/metabase/.env /opt - msg_ok "Created backup" + create_backup /opt/metabase/.env msg_info "Updating Metabase" RELEASE=$(get_latest_github_release "metabase/metabase") curl -fsSL "https://downloads.metabase.com/v${RELEASE}.x/metabase.jar" -o /opt/metabase/metabase.jar echo $RELEASE >~/.metabase + restore_backup msg_ok "Updated Metabase" - msg_info "Restoring backup" - mv /opt/.env /opt/metabase - msg_ok "Restored backup" - msg_info "Starting Service" systemctl start metabase msg_ok "Started Service" diff --git a/ct/monica.sh b/ct/monica.sh index 9d4172ac9..4657bc528 100644 --- a/ct/monica.sh +++ b/ct/monica.sh @@ -42,16 +42,13 @@ function update_script() { systemctl stop apache2 msg_ok "Stopped Service" - msg_info "Creating backup" - mv /opt/monica/ /opt/monica-backup - msg_ok "Backup created" + create_backup /opt/monica/.env /opt/monica/storage fetch_and_deploy_gh_release "monica" "monicahq/monica" "prebuild" "latest" "/opt/monica" "monica-v*.tar.bz2" + restore_backup msg_info "Configuring monica" cd /opt/monica/ - cp -r /opt/monica-backup/.env /opt/monica - cp -r /opt/monica-backup/storage/* /opt/monica/storage/ $STD composer install --no-interaction --no-dev $STD yarn config set ignore-engines true $STD yarn install @@ -59,7 +56,6 @@ function update_script() { $STD php artisan monica:update --force chown -R www-data:www-data /opt/monica chmod -R 775 /opt/monica/storage - rm -r /opt/monica-backup msg_ok "Configured monica" msg_info "Starting Service" diff --git a/ct/neko.sh b/ct/neko.sh index 107573757..dde79b0c6 100644 --- a/ct/neko.sh +++ b/ct/neko.sh @@ -36,9 +36,7 @@ function update_script() { systemctl stop neko msg_ok "Stopped Service" - msg_info "Backing up Data" - cp /etc/neko/neko.yaml /opt/neko.yaml.bak - msg_ok "Backed up Data" + create_backup /etc/neko/neko.yaml CLEAN_INSTALL=1 fetch_and_deploy_gh_release "neko" "m1k1o/neko" "tarball" @@ -56,10 +54,7 @@ function update_script() { cp -r /opt/neko/server/bin/plugins/* /etc/neko/plugins/ 2>/dev/null || true msg_ok "Built Server" - msg_info "Restoring Data" - cp /opt/neko.yaml.bak /etc/neko/neko.yaml - rm -f /opt/neko.yaml.bak - msg_ok "Restored Data" + restore_backup msg_info "Starting Service" systemctl start neko diff --git a/ct/netboot-xyz.sh b/ct/netboot-xyz.sh index 95e5b63a0..84a8bb2f5 100644 --- a/ct/netboot-xyz.sh +++ b/ct/netboot-xyz.sh @@ -33,9 +33,7 @@ function update_script() { fi if check_for_gh_release "netboot-xyz" "netbootxyz/netboot.xyz"; then - msg_info "Backing up Configuration" - cp /var/www/html/boot.cfg /opt/netboot-xyz-boot.cfg.bak - msg_ok "Backed up Configuration" + create_backup /var/www/html/boot.cfg CLEAN_INSTALL=1 fetch_and_deploy_gh_release "netboot-xyz" "netbootxyz/netboot.xyz" "prebuild" "latest" "/var/www/html" "menus.tar.gz" @@ -70,10 +68,7 @@ function update_script() { USE_ORIGINAL_FILENAME=true fetch_and_deploy_gh_release "netboot-xyz-multiarch-img" "netbootxyz/netboot.xyz" "singlefile" "latest" "/var/www/html" "netboot.xyz-multiarch.img" USE_ORIGINAL_FILENAME=true fetch_and_deploy_gh_release "netboot-xyz-checksums" "netbootxyz/netboot.xyz" "singlefile" "latest" "/var/www/html" "netboot.xyz-sha256-checksums.txt" - msg_info "Restoring Configuration" - cp /opt/netboot-xyz-boot.cfg.bak /var/www/html/boot.cfg - rm -f /opt/netboot-xyz-boot.cfg.bak - msg_ok "Restored Configuration" + restore_backup msg_ok "Updated successfully!" fi diff --git a/ct/nginx-ui.sh b/ct/nginx-ui.sh index 1f9c3ec69..7ad6b0213 100644 --- a/ct/nginx-ui.sh +++ b/ct/nginx-ui.sh @@ -35,9 +35,7 @@ function update_script() { systemctl stop nginx-ui msg_ok "Stopped Service" - msg_info "Backing up Configuration" - cp /usr/local/etc/nginx-ui/app.ini /tmp/nginx-ui-app.ini.bak - msg_ok "Backed up Configuration" + create_backup /usr/local/etc/nginx-ui/app.ini CLEAN_INSTALL=1 fetch_and_deploy_gh_release "nginx-ui" "0xJacky/nginx-ui" "prebuild" "latest" "/opt/nginx-ui" "nginx-ui-linux-64.tar.gz" @@ -45,12 +43,9 @@ function update_script() { cp /opt/nginx-ui/nginx-ui /usr/local/bin/nginx-ui chmod +x /usr/local/bin/nginx-ui rm -rf /opt/nginx-ui + restore_backup msg_ok "Updated Binary" - msg_info "Restoring Configuration" - mv /tmp/nginx-ui-app.ini.bak /usr/local/etc/nginx-ui/app.ini - msg_ok "Restored Configuration" - msg_info "Starting Service" systemctl start nginx-ui msg_ok "Started Service" diff --git a/ct/ombi.sh b/ct/ombi.sh index cbb8d4790..a8a218ab9 100644 --- a/ct/ombi.sh +++ b/ct/ombi.sh @@ -33,19 +33,11 @@ function update_script() { systemctl stop ombi msg_ok "Stopped Service" - msg_info "Creating backup" - [[ -f /opt/ombi/Ombi.db ]] && mv /opt/ombi/Ombi.db /opt - [[ -f /opt/ombi/OmbiExternal.db ]] && mv /opt/ombi/OmbiExternal.db /opt - [[ -f /opt/ombi/OmbiSettings.db ]] && mv /opt/ombi/OmbiSettings.db /opt - [[ -f /opt/ombi/database.json ]] && mv /opt/ombi/database.json /opt - msg_ok "Backup created" + create_backup /opt/ombi/Ombi.db /opt/ombi/OmbiExternal.db /opt/ombi/OmbiSettings.db /opt/ombi/database.json rm -rf /opt/ombi fetch_and_deploy_gh_release "ombi" "Ombi-app/Ombi" "prebuild" "latest" "/opt/ombi" "linux-x64.tar.gz" - [[ -f /opt/Ombi.db ]] && mv /opt/Ombi.db /opt/ombi - [[ -f /opt/OmbiExternal.db ]] && mv /opt/OmbiExternal.db /opt/ombi - [[ -f /opt/OmbiSettings.db ]] && mv /opt/OmbiSettings.db /opt/ombi - [[ -f /opt/database.json ]] && mv /opt/database.json /opt/ombi + restore_backup msg_info "Starting Service" systemctl start ombi diff --git a/ct/opengist.sh b/ct/opengist.sh index 2336b699c..de078f76e 100644 --- a/ct/opengist.sh +++ b/ct/opengist.sh @@ -33,15 +33,10 @@ function update_script() { systemctl stop opengist msg_ok "Stopped Service" - msg_info "Creating backup" - mv /opt/opengist /opt/opengist-backup - msg_ok "Backup created" + create_backup /opt/opengist/config.yml fetch_and_deploy_gh_release "opengist" "thomiceli/opengist" "prebuild" "latest" "/opt/opengist" "opengist*linux-amd64.tar.gz" - - msg_info "Restoring Configuration" - mv /opt/opengist-backup/config.yml /opt/opengist/config.yml - msg_ok "Configuration Restored" + restore_backup msg_info "Starting Service" systemctl start opengist diff --git a/ct/outline.sh b/ct/outline.sh index cf38d4bd2..bc7eed5b8 100644 --- a/ct/outline.sh +++ b/ct/outline.sh @@ -36,15 +36,13 @@ function update_script() { systemctl stop outline msg_ok "Services Stopped" - msg_info "Creating backup" - cp /opt/outline/.env /opt - msg_ok "Backup created" + create_backup /opt/outline/.env CLEAN_INSTALL=1 fetch_and_deploy_gh_release "outline" "outline/outline" "tarball" + restore_backup msg_info "Updating Outline" cd /opt/outline - mv /opt/.env /opt/outline export NODE_ENV=development export NODE_OPTIONS="--max-old-space-size=3584" export COREPACK_ENABLE_DOWNLOAD_PROMPT=0 diff --git a/ct/overseerr.sh b/ct/overseerr.sh index 431f24231..5d3c5f587 100644 --- a/ct/overseerr.sh +++ b/ct/overseerr.sh @@ -61,18 +61,15 @@ EOF systemctl stop overseerr msg_ok "Service stopped" - msg_info "Creating backup" - mv /opt/overseerr/config /opt/config_backup - msg_ok "Backup created" + create_backup /opt/overseerr/config fetch_and_deploy_gh_release "overseerr" "sct/overseerr" "tarball" - rm -rf /opt/overseerr/config msg_info "Configuring ${APP} (Patience)" cd /opt/overseerr $STD yarn install $STD yarn build - mv /opt/config_backup /opt/overseerr/config + restore_backup msg_ok "Configured ${APP}" msg_info "Starting Service" diff --git a/ct/paperclip.sh b/ct/paperclip.sh index ff61931a4..f7c7445af 100644 --- a/ct/paperclip.sh +++ b/ct/paperclip.sh @@ -35,15 +35,10 @@ function update_script() { systemctl stop paperclip msg_ok "Stopped Service" - msg_info "Backing up Configuration" - cp /opt/paperclip-ai/.env /opt/paperclip.env.bak - msg_ok "Backed up Configuration" + create_backup /opt/paperclip-ai/.env CLEAN_INSTALL=1 fetch_and_deploy_gh_release "paperclip-ai" "paperclipai/paperclip" "tarball" - - msg_info "Restoring Configuration" - mv /opt/paperclip.env.bak /opt/paperclip-ai/.env - msg_ok "Restored Configuration" + restore_backup msg_info "Rebuilding Paperclip" cd /opt/paperclip-ai diff --git a/ct/papra.sh b/ct/papra.sh index e3646edf4..2979e954f 100644 --- a/ct/papra.sh +++ b/ct/papra.sh @@ -35,11 +35,7 @@ function update_script() { systemctl stop papra msg_ok "Stopped Service" - msg_info "Backing up Configuration" - if [[ -f /opt/papra/apps/papra-server/.env ]]; then - cp /opt/papra/apps/papra-server/.env /opt/papra_env.bak - fi - msg_ok "Backed up Configuration" + create_backup /opt/papra/apps/papra-server/.env CLEAN_INSTALL=1 fetch_and_deploy_gh_release "papra" "papra-hq/papra" "tarball" @@ -48,9 +44,8 @@ function update_script() { msg_info "Building Application" cd /opt/papra - if [[ -f /opt/papra_env.bak ]]; then - cp /opt/papra_env.bak /opt/papra/apps/papra-server/.env - else + restore_backup + if [[ ! -f /opt/papra/apps/papra-server/.env ]]; then msg_warn ".env missing, regenerating from defaults" LOCAL_IP=$(hostname -I | awk '{print $1}') cat </opt/papra/apps/papra-server/.env @@ -74,7 +69,6 @@ EOF $STD pnpm --filter "@papra/app-client..." run build $STD pnpm --filter "@papra/app-server..." run build ln -sf /opt/papra/apps/papra-client/dist /opt/papra/apps/papra-server/public - rm -f /opt/papra_env.bak msg_ok "Built Application" msg_info "Starting Service" diff --git a/ct/powerdns.sh b/ct/powerdns.sh index b378c3f01..46f88b050 100644 --- a/ct/powerdns.sh +++ b/ct/powerdns.sh @@ -36,18 +36,13 @@ function update_script() { msg_ok "Updated PowerDNS" if check_for_gh_release "poweradmin" "poweradmin/poweradmin"; then - msg_info "Backing up Configuration" - cp /opt/poweradmin/config/settings.php /opt/poweradmin_settings.php.bak - cp /opt/poweradmin/powerdns.db /opt/poweradmin_powerdns.db.bak - msg_ok "Backed up Configuration" + create_backup /opt/poweradmin/config/settings.php /opt/poweradmin/powerdns.db CLEAN_INSTALL=1 fetch_and_deploy_gh_release "poweradmin" "poweradmin/poweradmin" "tarball" + restore_backup msg_info "Updating Poweradmin" - cp /opt/poweradmin_settings.php.bak /opt/poweradmin/config/settings.php - cp /opt/poweradmin_powerdns.db.bak /opt/poweradmin/powerdns.db rm -rf /opt/poweradmin/install - rm -f /opt/poweradmin_settings.php.bak /opt/poweradmin_powerdns.db.bak chown -R www-data:pdns /opt/poweradmin chmod 775 /opt/poweradmin chown pdns:pdns /opt/poweradmin/powerdns.db diff --git a/ct/prometheus-blackbox-exporter.sh b/ct/prometheus-blackbox-exporter.sh index 757e447b7..a5f95426b 100644 --- a/ct/prometheus-blackbox-exporter.sh +++ b/ct/prometheus-blackbox-exporter.sh @@ -34,16 +34,10 @@ function update_script() { systemctl stop blackbox-exporter msg_ok "Stopped Service" - msg_info "Creating backup" - mv /opt/blackbox-exporter/blackbox.yml /opt - msg_ok "Backup created" + create_backup /opt/blackbox-exporter/blackbox.yml CLEAN_INSTALL=1 fetch_and_deploy_gh_release "blackbox-exporter" "prometheus/blackbox_exporter" "prebuild" "latest" "/opt/blackbox-exporter" "blackbox_exporter-*.linux-amd64.tar.gz" - - msg_info "Restoring backup" - cp -r /opt/blackbox.yml /opt/blackbox-exporter - rm -f /opt/blackbox.yml - msg_ok "Backup restored" + restore_backup msg_info "Starting Service" systemctl start blackbox-exporter diff --git a/ct/reactive-resume.sh b/ct/reactive-resume.sh index 33dada404..ee87c831f 100644 --- a/ct/reactive-resume.sh +++ b/ct/reactive-resume.sh @@ -36,7 +36,8 @@ function update_script() { ensure_dependencies git - cp /opt/reactive-resume/.env /opt/reactive-resume.env.bak + create_backup /opt/reactive-resume/.env + NODE_VERSION="24" setup_nodejs CLEAN_INSTALL=1 fetch_and_deploy_gh_release "reactive-resume" "amruthpillai/reactive-resume" "tarball" "latest" "/opt/reactive-resume" @@ -49,7 +50,7 @@ function update_script() { export NODE_ENV="production" $STD pnpm install --frozen-lockfile $STD pnpm run build - mv /opt/reactive-resume.env.bak /opt/reactive-resume/.env + restore_backup msg_ok "Updated Reactive Resume" msg_info "Updating Service" diff --git a/ct/romm.sh b/ct/romm.sh index dc49b8af7..6216ad0a7 100644 --- a/ct/romm.sh +++ b/ct/romm.sh @@ -37,14 +37,12 @@ function update_script() { systemctl stop romm-backend romm-worker romm-scheduler romm-watcher msg_ok "Stopped Services" - msg_info "Backing up configuration" - cp /opt/romm/.env /opt/romm/.env.backup - msg_ok "Backed up configuration" + create_backup /opt/romm/.env fetch_and_deploy_gh_release "romm" "rommapp/romm" "tarball" "latest" "/opt/romm" + restore_backup msg_info "Updating ROMM" - cp /opt/romm/.env.backup /opt/romm/.env cd /opt/romm $STD uv sync --all-extras cd /opt/romm/backend diff --git a/ct/rustypaste.sh b/ct/rustypaste.sh index d62ae7812..85a271fb1 100644 --- a/ct/rustypaste.sh +++ b/ct/rustypaste.sh @@ -35,18 +35,10 @@ function update_script() { systemctl stop rustypaste msg_ok "Stopped Services" - msg_info "Creating Backup" - tar -czf "/opt/rustypaste_backup_$(date +%F).tar.gz" /opt/rustypaste/upload 2>/dev/null || true - cp /opt/rustypaste/config.toml /tmp/rustypaste_config.toml.bak - msg_ok "Backup Created" + create_backup /opt/rustypaste/config.toml /opt/rustypaste/upload CLEAN_INSTALL=1 fetch_and_deploy_gh_release "rustypaste" "orhun/rustypaste" "prebuild" "latest" "/opt/rustypaste" "*x86_64-unknown-linux-gnu.tar.gz" - - msg_info "Restoring Data" - mv /tmp/rustypaste_config.toml.bak /opt/rustypaste/config.toml - tar -xzf "/opt/rustypaste_backup_$(date +%F).tar.gz" -C /opt/rustypaste/upload 2>/dev/null || true - rm -rf /opt/rustypaste_backup_$(date +%F).tar.gz - msg_ok "Restored Data" + restore_backup msg_info "Starting Services" systemctl start rustypaste diff --git a/ct/seerr.sh b/ct/seerr.sh index 4ea49c8f8..b4192044c 100644 --- a/ct/seerr.sh +++ b/ct/seerr.sh @@ -123,9 +123,7 @@ EOF systemctl stop seerr msg_ok "Stopped Service" - msg_info "Creating Backup" - cp -a /opt/seerr/config /opt/seerr_backup - msg_ok "Created Backup" + create_backup /opt/seerr/config CLEAN_INSTALL=1 fetch_and_deploy_gh_release "seerr" "seerr-team/seerr" "tarball" @@ -145,10 +143,7 @@ EOF $STD pnpm build msg_ok "Updated Seerr" - msg_info "Restoring Backup" - rm -rf /opt/seerr/config - mv /opt/seerr_backup /opt/seerr/config - msg_ok "Restored Backup" + restore_backup msg_info "Starting Service" systemctl start seerr diff --git a/ct/slskd.sh b/ct/slskd.sh index 474ee1dd3..3e8009f31 100644 --- a/ct/slskd.sh +++ b/ct/slskd.sh @@ -36,14 +36,10 @@ function update_script() { [[ -f /etc/systemd/system/soularr.service ]] && systemctl stop soularr.timer soularr.service msg_ok "Stopped Service(s)" - msg_info "Backing up config" - cp /opt/slskd/config/slskd.yml /opt/slskd.yml.bak - msg_ok "Backed up config" + create_backup /opt/slskd/config/slskd.yml CLEAN_INSTALL=1 fetch_and_deploy_gh_release "Slskd" "slskd/slskd" "prebuild" "latest" "/opt/slskd" "slskd-*-linux-x64.zip" - - msg_info "Restoring config" - mv /opt/slskd.yml.bak /opt/slskd/config/slskd.yml + restore_backup # Migrate 0.25.0 breaking config key renames sed -i 's/^global:/transfers:/' /opt/slskd/config/slskd.yml @@ -63,13 +59,12 @@ function update_script() { msg_ok "Stopped Timer and Service" fi - msg_info "Backing up Soularr config" - cp /opt/soularr/config.ini /opt/soularr_config.ini.bak - cp /opt/soularr/run.sh /opt/soularr_run.sh.bak - msg_ok "Backed up Soularr config" + create_backup /opt/soularr/config.ini /opt/soularr/run.sh PYTHON_VERSION="3.11" setup_uv CLEAN_INSTALL=1 fetch_and_deploy_gh_release "Soularr" "mrusse/soularr" "tarball" "latest" "/opt/soularr" + restore_backup + msg_info "Updating Soularr" cd /opt/soularr $STD uv venv -c venv @@ -78,11 +73,6 @@ function update_script() { deactivate msg_ok "Updated Soularr" - msg_info "Restoring Soularr config" - mv /opt/soularr_config.ini.bak /opt/soularr/config.ini - mv /opt/soularr_run.sh.bak /opt/soularr/run.sh - msg_ok "Restored Soularr config" - msg_info "Starting Soularr Timer" systemctl restart soularr.timer msg_ok "Started Soularr Timer" diff --git a/ct/speedtest-tracker.sh b/ct/speedtest-tracker.sh index aadbba0d6..1d6b934b9 100644 --- a/ct/speedtest-tracker.sh +++ b/ct/speedtest-tracker.sh @@ -45,14 +45,12 @@ function update_script() { $STD apt --only-upgrade install -y speedtest msg_ok "Updated Speedtest CLI" - msg_info "Creating Backup" - cp -r /opt/speedtest-tracker /opt/speedtest-tracker-backup - msg_ok "Backup Created" + create_backup /opt/speedtest-tracker/.env fetch_and_deploy_gh_release "speedtest-tracker" "alexjustesen/speedtest-tracker" "tarball" "latest" "/opt/speedtest-tracker" + restore_backup msg_info "Updating Speedtest Tracker" - cp -r /opt/speedtest-tracker-backup/.env /opt/speedtest-tracker/.env cd /opt/speedtest-tracker export COMPOSER_ALLOW_SUPERUSER=1 $STD composer install --optimize-autoloader --no-dev diff --git a/ct/spliit.sh b/ct/spliit.sh index 33076cd42..6c2d86467 100755 --- a/ct/spliit.sh +++ b/ct/spliit.sh @@ -35,16 +35,10 @@ function update_script() { systemctl stop spliit msg_ok "Stopped Service" - msg_info "Backing up Configuration" - rm -f /opt/spliit.env.bak - cp /opt/spliit/.env /opt/spliit.env.bak - msg_ok "Backed up Configuration" + create_backup /opt/spliit/.env CLEAN_INSTALL=1 fetch_and_deploy_gh_release "spliit" "spliit-app/spliit" "tarball" - - msg_info "Restoring Configuration" - cp /opt/spliit.env.bak /opt/spliit/.env - msg_ok "Restored Configuration" + restore_backup msg_info "Building Application" cd /opt/spliit diff --git a/ct/storyteller.sh b/ct/storyteller.sh index a461a6d02..9d36ea2c5 100644 --- a/ct/storyteller.sh +++ b/ct/storyteller.sh @@ -35,15 +35,10 @@ function update_script() { systemctl stop storyteller msg_ok "Stopped Service" - msg_info "Backing up Data" - cp /opt/storyteller/.env /opt/storyteller_env.bak - msg_ok "Backed up Data" + create_backup /opt/storyteller/.env CLEAN_INSTALL=1 fetch_and_deploy_gl_release "storyteller" "storyteller-platform/storyteller" "tarball" "latest" "/opt/storyteller" - - msg_info "Restoring Configuration" - mv /opt/storyteller_env.bak /opt/storyteller/.env - msg_ok "Restored Configuration" + restore_backup msg_info "Rebuilding Storyteller" cd /opt/storyteller diff --git a/ct/teable.sh b/ct/teable.sh index 5d8935f80..9ac0092bb 100644 --- a/ct/teable.sh +++ b/ct/teable.sh @@ -36,15 +36,10 @@ function update_script() { systemctl stop teable msg_ok "Stopped Service" - msg_info "Backing up Configuration" - cp /opt/teable/.env /opt/teable.env.bak - msg_ok "Backed up Configuration" + create_backup /opt/teable/.env CLEAN_INSTALL=1 fetch_and_deploy_gh_release "teable" "teableio/teable" "tarball" - - msg_info "Restoring Configuration" - mv /opt/teable.env.bak /opt/teable/.env - msg_ok "Restored Configuration" + restore_backup msg_info "Rebuilding Teable" cd /opt/teable diff --git a/ct/teddycloud.sh b/ct/teddycloud.sh index a0216d678..14b5d34b4 100644 --- a/ct/teddycloud.sh +++ b/ct/teddycloud.sh @@ -34,16 +34,10 @@ function update_script() { systemctl stop teddycloud msg_ok "Stopped Service" - msg_info "Creating backup" - mv /opt/teddycloud /opt/teddycloud_bak - msg_ok "Backup created" + create_backup /opt/teddycloud/certs /opt/teddycloud/config /opt/teddycloud/data CLEAN_INSTALL=1 fetch_and_deploy_gh_release "teddycloud" "toniebox-reverse-engineering/teddycloud" "prebuild" "latest" "/opt/teddycloud" "teddycloud.amd64.release*.zip" - - msg_info "Restoring data" - cp -R /opt/teddycloud_bak/certs /opt/teddycloud_bak/config /opt/teddycloud_bak/data /opt/teddycloud - rm -rf /opt/teddycloud_bak - msg_ok "Data restored" + restore_backup msg_info "Starting Service" systemctl start teddycloud diff --git a/ct/traccar.sh b/ct/traccar.sh index 1d482d8b5..7057d8b8c 100644 --- a/ct/traccar.sh +++ b/ct/traccar.sh @@ -34,11 +34,7 @@ function update_script() { systemctl stop traccar msg_ok "Stopped Service" - msg_info "Creating backup" - mv /opt/traccar/conf/traccar.xml /opt - [[ -d /opt/traccar/data ]] && mv /opt/traccar/data /opt - [[ -d /opt/traccar/media ]] && mv /opt/traccar/media /opt - msg_ok "Backup created" + create_backup /opt/traccar/conf/traccar.xml /opt/traccar/data /opt/traccar/media CLEAN_INSTALL=1 fetch_and_deploy_gh_release "traccar" "traccar/traccar" "prebuild" "latest" "/opt/traccar" "traccar-linux-64*.zip" @@ -47,12 +43,8 @@ function update_script() { $STD ./traccar.run msg_ok "App-Update completed" - msg_info "Restoring data" - mv /opt/traccar.xml /opt/traccar/conf - [[ -d /opt/data ]] && mv /opt/data /opt/traccar - [[ -d /opt/media ]] && mv /opt/media /opt/traccar + restore_backup [ -f README.txt ] || [ -f traccar.run ] && rm -f README.txt traccar.run - msg_ok "Data restored" msg_info "Starting Service" systemctl start traccar diff --git a/ct/tubearchivist.sh b/ct/tubearchivist.sh index a087e7d27..942f3c5c6 100644 --- a/ct/tubearchivist.sh +++ b/ct/tubearchivist.sh @@ -35,9 +35,7 @@ function update_script() { systemctl stop tubearchivist tubearchivist-celery tubearchivist-beat msg_ok "Stopped Services" - msg_info "Backing up Data" - cp /opt/tubearchivist/.env /opt/tubearchivist_env.bak - msg_ok "Backed up Data" + create_backup /opt/tubearchivist/.env CLEAN_INSTALL=1 fetch_and_deploy_gh_release "tubearchivist" "tubearchivist/tubearchivist" "tarball" @@ -55,8 +53,7 @@ function update_script() { fi msg_ok "Rebuilt Tube Archivist" - msg_info "Restoring Configuration" - mv /opt/tubearchivist_env.bak /opt/tubearchivist/.env + restore_backup sed -i 's|^TA_APP_DIR=/opt/tubearchivist$|TA_APP_DIR=/opt/tubearchivist/backend|' /opt/tubearchivist/.env sed -i 's|^TA_CACHE_DIR=/opt/tubearchivist/cache$|TA_CACHE_DIR=/cache|' /opt/tubearchivist/.env sed -i 's|^TA_MEDIA_DIR=/opt/tubearchivist/media$|TA_MEDIA_DIR=/youtube|' /opt/tubearchivist/.env diff --git a/ct/wallabag.sh b/ct/wallabag.sh index 40fbc066b..7f10259c7 100644 --- a/ct/wallabag.sh +++ b/ct/wallabag.sh @@ -38,16 +38,10 @@ function update_script() { systemctl stop nginx php8.3-fpm msg_ok "Stopped Services" - msg_info "Creating Backup" - cp /opt/wallabag/app/config/parameters.yml /tmp/wallabag_parameters.yml.bak - msg_ok "Created Backup" + create_backup /opt/wallabag/app/config/parameters.yml CLEAN_INSTALL=1 fetch_and_deploy_gh_release "wallabag" "wallabag/wallabag" "prebuild" "latest" "/opt/wallabag" "wallabag-*.tar.gz" - - msg_info "Restoring Configuration" - cp /tmp/wallabag_parameters.yml.bak /opt/wallabag/app/config/parameters.yml - rm -f /tmp/wallabag_parameters.yml.bak - msg_ok "Restored Configuration" + restore_backup msg_info "Running Migrations" cd /opt/wallabag diff --git a/ct/wallos.sh b/ct/wallos.sh index f28b5846a..1e0353c74 100644 --- a/ct/wallos.sh +++ b/ct/wallos.sh @@ -30,18 +30,13 @@ function update_script() { fi if check_for_gh_release "wallos" "ellite/Wallos"; then - msg_info "Creating backup" - mkdir -p /opt/logos - mv /opt/wallos/db/wallos.db /opt/wallos.db - mv /opt/wallos/images/uploads/logos /opt/logos/ - msg_ok "Backup created" + create_backup /opt/wallos/db/wallos.db /opt/wallos/images/uploads/logos CLEAN_INSTALL=1 fetch_and_deploy_gh_release "wallos" "ellite/Wallos" "tarball" + restore_backup msg_info "Configuring Wallos" rm -rf /opt/wallos/db/wallos.empty.db - mv /opt/wallos.db /opt/wallos/db/wallos.db - mv /opt/logos/* /opt/wallos/images/uploads/logos if ! grep -q "storetotalyearlycost.php" /opt/wallos.cron; then echo "30 1 * * 1 php /opt/wallos/endpoints/cronjobs/storetotalyearlycost.php >> /var/log/cron/storetotalyearlycost.log 2>&1" >>/opt/wallos.cron fi diff --git a/ct/wavelog.sh b/ct/wavelog.sh index 0e2731f2a..de4ab44cc 100644 --- a/ct/wavelog.sh +++ b/ct/wavelog.sh @@ -34,27 +34,16 @@ function update_script() { systemctl stop apache2 msg_ok "Services Stopped" - msg_info "Creating backup" - cp /opt/wavelog/application/config/config.php /opt/config.php - cp /opt/wavelog/application/config/database.php /opt/database.php - cp -r /opt/wavelog/userdata /opt/userdata - if [[ -f /opt/wavelog/assets/js/sections/custom.js ]]; then - cp /opt/wavelog/assets/js/sections/custom.js /opt/custom.js - fi - msg_ok "Backup created" + create_backup /opt/wavelog/application/config/config.php \ + /opt/wavelog/application/config/database.php \ + /opt/wavelog/userdata \ + /opt/wavelog/assets/js/sections/custom.js - rm -rf /opt/wavelog fetch_and_deploy_gh_release "wavelog" "wavelog/wavelog" "tarball" + restore_backup msg_info "Updating Wavelog" rm -rf /opt/wavelog/install - mv /opt/config.php /opt/wavelog/application/config/config.php - mv /opt/database.php /opt/wavelog/application/config/database.php - cp -r /opt/userdata/* /opt/wavelog/userdata - rm -rf /opt/userdata - if [[ -f /opt/custom.js ]]; then - mv /opt/custom.js /opt/wavelog/assets/js/sections/custom.js - fi chown -R www-data:www-data /opt/wavelog/ find /opt/wavelog/ -type d -exec chmod 755 {} \; find /opt/wavelog/ -type f -exec chmod 664 {} \; diff --git a/ct/writefreely.sh b/ct/writefreely.sh index daf3f6dcb..cced90c81 100644 --- a/ct/writefreely.sh +++ b/ct/writefreely.sh @@ -35,19 +35,10 @@ function update_script() { systemctl stop writefreely msg_ok "Stopped Services" - msg_info "Creating Backup" - mkdir -p /tmp/writefreely_backup - cp /opt/writefreely/keys /tmp/writefreely_backup/ 2>/dev/null - cp /opt/writefreely/config.ini /tmp/writefreely_backup/ 2>/dev/null - msg_ok "Created Backup" + create_backup /opt/writefreely/keys /opt/writefreely/config.ini CLEAN_INSTALL=1 fetch_and_deploy_gh_release "writefreely" "writefreely/writefreely" "prebuild" "latest" "/opt/writefreely" "writefreely_*_linux_amd64.tar.gz" - - msg_info "Restoring Data" - cp /tmp/writefreely_backup/config.ini /opt/writefreely/ 2>/dev/null - cp /tmp/writefreely_backup/keys/* /opt/writefreely/keys/ 2>/dev/null - rm -rf /tmp/writefreely_backup - msg_ok "Restored Data" + restore_backup msg_info "Running Post-Update Tasks" cd /opt/writefreely diff --git a/ct/yamtrack.sh b/ct/yamtrack.sh index 06eba2335..ac7542aed 100644 --- a/ct/yamtrack.sh +++ b/ct/yamtrack.sh @@ -36,9 +36,7 @@ function update_script() { systemctl stop yamtrack yamtrack-celery msg_ok "Stopped Services" - msg_info "Backing up Data" - cp /opt/yamtrack/src/.env /opt/yamtrack_env.bak - msg_ok "Backed up Data" + create_backup /opt/yamtrack/src/.env CLEAN_INSTALL=1 fetch_and_deploy_gh_release "yamtrack" "FuzzyGrim/Yamtrack" "tarball" @@ -47,10 +45,7 @@ function update_script() { $STD uv sync --locked msg_ok "Installed Python Dependencies" - msg_info "Restoring Data" - cp /opt/yamtrack_env.bak /opt/yamtrack/src/.env - rm -f /opt/yamtrack_env.bak - msg_ok "Restored Data" + restore_backup msg_info "Updating Yamtrack" cd /opt/yamtrack/src diff --git a/ct/zerobyte.sh b/ct/zerobyte.sh index 16b3bd17b..4613435f6 100644 --- a/ct/zerobyte.sh +++ b/ct/zerobyte.sh @@ -35,10 +35,8 @@ function update_script() { systemctl stop zerobyte msg_ok "Stopped Service" - msg_info "Backing up Configuration" - cp /opt/zerobyte/.env /opt/zerobyte.env.bak - msg_ok "Backed up Configuration" - + create_backup /opt/zerobyte/.env + ensure_dependencies git NODE_VERSION="24" setup_nodejs CLEAN_INSTALL=1 fetch_and_deploy_gh_release "zerobyte" "nicotsx/zerobyte" "tarball" @@ -50,10 +48,7 @@ function update_script() { $STD node ./node_modules/vite/bin/vite.js build msg_ok "Built Zerobyte" - msg_info "Restoring Configuration" - cp /opt/zerobyte.env.bak /opt/zerobyte/.env - rm -f /opt/zerobyte.env.bak - msg_ok "Restored Configuration" + restore_backup msg_info "Starting Service" systemctl start zerobyte diff --git a/ct/zigbee2mqtt.sh b/ct/zigbee2mqtt.sh index 2520d7d7b..41db74cc6 100644 --- a/ct/zigbee2mqtt.sh +++ b/ct/zigbee2mqtt.sh @@ -42,19 +42,17 @@ function update_script() { BACKUP_FILE="/opt/backups/${APP}_backup_${BACKUP_VERSION}.tar.zst" $STD tar -cf - -C /opt zigbee2mqtt | zstd -q -o "$BACKUP_FILE" ls -t /opt/backups/${APP}_backup_*.tar.zst 2>/dev/null | tail -n +6 | xargs -r rm -f - mv /opt/zigbee2mqtt/data /opt/z2m_backup/data + create_backup /opt/zigbee2mqtt/data msg_ok "Backup Created (${BACKUP_VERSION})" CLEAN_INSTALL=1 fetch_and_deploy_gh_release "Zigbee2MQTT" "Koenkk/zigbee2mqtt" "tarball" "latest" "/opt/zigbee2mqtt" + restore_backup msg_info "Updating Zigbee2MQTT" - rm -rf /opt/zigbee2mqtt/data - mv /opt/z2m_backup/data /opt/zigbee2mqtt cd /opt/zigbee2mqtt grep -q "^packageImportMethod" ./pnpm-workspace.yaml 2>/dev/null || echo "packageImportMethod: hardlink" >>./pnpm-workspace.yaml $STD pnpm install --frozen-lockfile $STD pnpm build - rm -rf /opt/z2m_backup msg_ok "Updated Zigbee2MQTT" msg_info "Starting Service"