From c9c456f3409d6a4b3c9bdcebd54422998d489bac Mon Sep 17 00:00:00 2001 From: MickLesk Date: Fri, 19 Jun 2026 22:47:03 +0200 Subject: [PATCH 1/4] feat(tools): auto-restore update backups on failure Arm create_backup with an ERR trap, add clear_update_backup, and ship a CI checker for update scripts that mutate config without backups. Co-authored-by: Cursor --- misc/tools.func | 20 +++++++++++++ tools/ci/check-update-backup.sh | 50 +++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100755 tools/ci/check-update-backup.sh diff --git a/misc/tools.func b/misc/tools.func index 6a0c3ed881c..72183c84235 100644 --- a/misc/tools.func +++ b/misc/tools.func @@ -1162,6 +1162,7 @@ create_backup() { if [[ -f "$manifest" ]]; then msg_ok "Existing backup found at ${store}, skipping backup" + trap '_restore_update_backup_on_error' ERR return 0 fi @@ -1186,6 +1187,24 @@ create_backup() { echo "$path" >>"$manifest" done msg_ok "Backed up data to ${store}" + trap '_restore_update_backup_on_error' ERR +} + +_restore_update_backup_on_error() { + local _err=$? + trap - ERR + if [[ -f "${BACKUP_DIR:-/opt/${NSAPP:-app}.backup}/.manifest" ]]; then + msg_error "Update failed (exit ${_err}) – restoring backup" + restore_backup + fi + exit "${_err:-1}" +} + +clear_update_backup() { + local store="${BACKUP_DIR:-/opt/${NSAPP:-app}.backup}" + [[ -d "$store" ]] || return 0 + rm -rf "$store" + trap - ERR } restore_backup() { @@ -1208,6 +1227,7 @@ restore_backup() { cp -a "$src" "$path" done <"$manifest" rm -rf "$store" + trap - ERR msg_ok "Restored data" } diff --git a/tools/ci/check-update-backup.sh b/tools/ci/check-update-backup.sh new file mode 100755 index 00000000000..fe84750a7c6 --- /dev/null +++ b/tools/ci/check-update-backup.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +# Copyright (c) 2021-2026 community-scripts ORG +# License: MIT +# +# Flags ct/*.sh update_script blocks that mutate config/data destructively +# without calling create_backup. Used in CI / local review before merge. + +set -euo pipefail + +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +CT_DIR="${ROOT}/ct" +FAIL=0 +CHECKED=0 +FLAGGED=0 + +check_file() { + local file="$1" + local base content block + base="$(basename "$file")" + content="$(<"$file")" + [[ "$content" == *"function update_script"* ]] || return 0 + CHECKED=$((CHECKED + 1)) + + block="$(python3 - "$file" <<'PY' +import re, sys +text = open(sys.argv[1]).read() +m = re.search(r'function update_script\(\).*?(?=^function |\Z)', text, re.S | re.M) +print(m.group() if m else "") +PY +)" + + [[ -n "$block" ]] || return 0 + [[ "$block" == *"create_backup"* ]] && return 0 + + if echo "$block" | grep -qE 'sed -i|\.env|settings\.(py|json)|config\.(json|yml|yaml)|/etc/[^ ]+\.(conf|env)'; then + if echo "$block" | grep -qE 'rm -rf|find .* -delete|mv .*\.(bak|old)'; then + echo "MISSING create_backup: ct/${base}" + FLAGGED=$((FLAGGED + 1)) + FAIL=1 + fi + fi +} + +for f in "$CT_DIR"/*.sh; do + [[ -f "$f" ]] || continue + check_file "$f" +done + +echo "Checked ${CHECKED} update scripts, flagged ${FLAGGED} without create_backup" +exit "$FAIL" From 578089b69ea7365a61ffddff6ce855e8ea303a19 Mon Sep 17 00:00:00 2001 From: MickLesk Date: Fri, 19 Jun 2026 23:29:44 +0200 Subject: [PATCH 2/4] chore(ci): add create_backup gap report for update scripts Summarize how many CT update_script blocks still need backup migration. Co-authored-by: Cursor --- tools/ci/report-create-backup-gaps.sh | 79 +++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100755 tools/ci/report-create-backup-gaps.sh diff --git a/tools/ci/report-create-backup-gaps.sh b/tools/ci/report-create-backup-gaps.sh new file mode 100755 index 00000000000..9f8691541ea --- /dev/null +++ b/tools/ci/report-create-backup-gaps.sh @@ -0,0 +1,79 @@ +#!/usr/bin/env bash +# Report CT scripts that should use create_backup during update_script. +# Usage: ./tools/ci/report-create-backup-gaps.sh [--summary] + +set -euo pipefail +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +SUMMARY="${1:-}" + +python3 - "$ROOT" "$SUMMARY" <<'PY' +import os, re, sys + +root, summary = sys.argv[1], sys.argv[2] +ct = os.path.join(root, 'ct') + +def block(text): + m = re.search(r'function update_script\(\).*?(?=^function |\Z)', text, re.S | re.M) + return m.group() if m else '' + +cats = { + 'has_backup': [], + 'config_mutation': [], + 'fetch_deploy': [], + 'package_only': [], + 'docker_only': [], + 'fetch_binary_only': [], + 'other': [], +} + +for f in sorted(os.listdir(ct)): + if not f.endswith('.sh'): + continue + text = open(os.path.join(ct, f)).read() + b = block(text) + if not b: + continue + if 'create_backup' in b: + cats['has_backup'].append(f) + continue + if re.search(r'sed -i|\.env|settings\.(py|json)|config\.(json|yml|yaml)', b): + cats['config_mutation'].append(f) + elif re.search(r'fetch_and_deploy_gh_release', b) and re.search(r'rm -rf', b): + if re.search(r'sed -i|\.env|settings\.|config\.', b): + cats['fetch_deploy'].append(f) + else: + cats['fetch_binary_only'].append(f) + elif re.search(r'fetch_and_deploy_gh_release', b): + cats['fetch_deploy'].append(f) + elif re.search(r'docker (pull|compose|image)', b): + cats['docker_only'].append(f) + elif re.search(r'\$STD apt|\$STD apk|pip install|npm install|yarn install|uv pip', b) and not re.search(r'rm -rf|sed -i', b): + cats['package_only'].append(f) + else: + cats['other'].append(f) + +total = sum(len(v) for v in cats.values()) +need_high = len(cats['config_mutation']) +need_review = len(cats['fetch_deploy']) + len(cats['fetch_binary_only']) + len(cats['other']) + +if summary == '--summary': + print(f"update_script gesamt: {total}") + print(f"bereits create_backup: {len(cats['has_backup'])}") + print(f"PRIORITÄT (Config): {need_high}") + print(f"PRÜFEN (fetch/other): {need_review}") + print(f"meist OK (nur Pakete): {len(cats['package_only']) + len(cats['docker_only'])}") + print(f"→ realistisch migrieren: ~{need_high + need_review} Skripte") +else: + for label, files in [ + ('PRIORITÄT config_mutation', cats['config_mutation']), + ('PRÜFEN fetch_deploy', cats['fetch_deploy']), + ('PRÜFEN fetch_binary_only', cats['fetch_binary_only']), + ('PRÜFEN other', cats['other']), + ('OK package_only', cats['package_only']), + ('OK docker_only', cats['docker_only']), + ('DONE has_backup', cats['has_backup']), + ]: + print(f"\n## {label} ({len(files)})") + for f in files: + print(f) +PY From a1f4bc32407a43111ce435135d5f4a66759d13fe Mon Sep 17 00:00:00 2001 From: MickLesk Date: Fri, 19 Jun 2026 23:35:15 +0200 Subject: [PATCH 3/4] refactor(ct): migrate manual update backups to create_backup (batch 1) Replace ad-hoc mv/cp .bak patterns with create_backup/restore_backup across 58 update scripts so failed updates can roll back via the shared ERR trap. Co-authored-by: Cursor --- ct/ezbookkeeping.sh | 14 ++------------ ct/fireshare.sh | 5 +++-- ct/flatnotes.sh | 12 ++---------- ct/freshrss.sh | 16 ++-------------- ct/ghostfolio.sh | 11 ++--------- ct/github-runner.sh | 15 ++------------- ct/gogs.sh | 11 ++--------- ct/healthchecks.sh | 6 ++---- ct/homelable.sh | 19 +++---------------- ct/homepage.sh | 18 +++--------------- ct/hortusfox.sh | 9 ++------- ct/immichframe.sh | 10 ++-------- ct/invoiceninja.sh | 11 ++--------- ct/invoiceshelf.sh | 12 ++---------- ct/jotty.sh | 12 ++---------- ct/koel.sh | 11 ++--------- ct/leantime.sh | 13 ++----------- ct/linkding.sh | 12 ++---------- ct/linkwarden.sh | 9 ++------- ct/listmonk.sh | 8 ++------ ct/lubelogger.sh | 17 ++--------------- ct/lychee.sh | 12 ++---------- ct/mafl.sh | 10 +++------- ct/magicmirror.sh | 15 ++------------- ct/mail-archiver.sh | 9 ++------- ct/manyfold.sh | 16 ++-------------- ct/matomo.sh | 21 ++------------------- ct/mealie.sh | 5 ++--- ct/metube.sh | 14 ++------------ ct/musicseerr.sh | 12 ++---------- ct/nagios.sh | 10 ++-------- ct/nametag.sh | 12 ++---------- ct/netbox.sh | 15 +++++---------- ct/ownfoil.sh | 9 ++------- ct/pangolin.sh | 13 ++----------- ct/paperless-ai.sh | 9 ++------- ct/pocketid.sh | 5 +++-- ct/privatebin.sh | 6 ++---- ct/shlink.sh | 12 ++---------- ct/snipeit.sh | 9 ++------- ct/solidtime.sh | 12 ++---------- ct/soulsync.sh | 9 ++------- ct/sparkyfitness.sh | 15 ++------------- ct/spoolman.sh | 5 ++--- ct/tandoor.sh | 8 ++------ ct/termix.sh | 11 ++--------- ct/tianji.sh | 8 ++------ ct/transmute.sh | 12 ++---------- ct/trilium.sh | 12 ++---------- ct/twenty.sh | 7 +------ ct/umami.sh | 5 +++-- ct/wealthfolio.sh | 11 ++--------- ct/web-check.sh | 8 ++------ ct/webtrees.sh | 10 ++-------- ct/wger.sh | 12 ++---------- ct/wishlist.sh | 14 ++------------ ct/xyops.sh | 11 ++--------- ct/yourls.sh | 9 ++------- 58 files changed, 124 insertions(+), 520 deletions(-) diff --git a/ct/ezbookkeeping.sh b/ct/ezbookkeeping.sh index 4035142d856..8f710000b86 100644 --- a/ct/ezbookkeeping.sh +++ b/ct/ezbookkeeping.sh @@ -35,21 +35,11 @@ function update_script() { systemctl stop ezbookkeeping msg_ok "Stopped Service" - msg_info "Backing up configuration" - mkdir -p /opt/ezbookkeeping-backup - cp /opt/ezbookkeeping/conf/ezbookkeeping.ini /opt/ezbookkeeping-backup/ - cp -r /opt/ezbookkeeping/data /opt/ezbookkeeping-backup/data/ - cp -r /opt/ezbookkeeping/storage /opt/ezbookkeeping-backup/storage/ - msg_ok "Backed up configuration" + create_backup /opt/ezbookkeeping/data /opt/ezbookkeeping/storage CLEAN_INSTALL=1 fetch_and_deploy_gh_release "ezbookkeeping" "mayswind/ezbookkeeping" "prebuild" "latest" "/opt/ezbookkeeping" "ezbookkeeping-*-linux-$(arch_resolve).tar.gz" + restore_backup - msg_info "Restoring configuration" - cp -rf /opt/ezbookkeeping-backup/ezbookkeeping.ini /opt/ezbookkeeping/conf/ - cp -rf /opt/ezbookkeeping-backup/data/. /opt/ezbookkeeping/data/ - cp -rf /opt/ezbookkeeping-backup/storage/. /opt/ezbookkeeping/storage/ - rm -rf /opt/ezbookkeeping-backup - msg_ok "Restored configuration" msg_info "Starting Service" systemctl start ezbookkeeping diff --git a/ct/fireshare.sh b/ct/fireshare.sh index 296cb6c010c..34d2836e206 100644 --- a/ct/fireshare.sh +++ b/ct/fireshare.sh @@ -35,9 +35,10 @@ function update_script() { systemctl stop fireshare msg_ok "Stopped Service" - mv /opt/fireshare/fireshare.env /opt + create_backup /opt/fireshare/fireshare.env + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "fireshare" "ShaneIsrael/fireshare" "tarball" - mv /opt/fireshare.env /opt/fireshare + restore_backup rm -f /usr/local/bin/fireshare msg_info "Updating Fireshare" diff --git a/ct/flatnotes.sh b/ct/flatnotes.sh index 3f48dc3262c..6cd59f764f0 100644 --- a/ct/flatnotes.sh +++ b/ct/flatnotes.sh @@ -34,12 +34,10 @@ function update_script() { systemctl stop flatnotes msg_ok "Stopped Service" - msg_info "Backing up Configuration and Data" - cp /opt/flatnotes/.env /opt/flatnotes.env - cp -r /opt/flatnotes/data /opt/flatnotes_data_backup - msg_ok "Backed up Configuration and Data" + create_backup /opt/flatnotes/data fetch_and_deploy_gh_release "flatnotes" "dullage/flatnotes" "tarball" + restore_backup msg_info "Updating Flatnotes" cd /opt/flatnotes/client @@ -52,12 +50,6 @@ function update_script() { $STD /usr/local/bin/uv sync msg_ok "Updated Flatnotes" - msg_info "Restoring Configuration and Data" - cp /opt/flatnotes.env /opt/flatnotes/.env - cp -r /opt/flatnotes_data_backup/. /opt/flatnotes/data - rm -f /opt/flatnotes.env - rm -r /opt/flatnotes_data_backup - msg_ok "Restored Configuration and Data" msg_info "Starting Service" systemctl start flatnotes diff --git a/ct/freshrss.sh b/ct/freshrss.sh index 096da271df2..f1894ea0e5d 100644 --- a/ct/freshrss.sh +++ b/ct/freshrss.sh @@ -41,20 +41,11 @@ function update_script() { systemctl stop apache2 msg_ok "Stopped Apache2" - msg_info "Backing up FreshRSS" - mv /opt/freshrss /opt/freshrss-backup - msg_ok "Backup Created" + create_backup /opt/freshrss /opt/freshrss/data /opt/freshrss/extensions fetch_and_deploy_gh_release "freshrss" "FreshRSS/FreshRSS" "tarball" + restore_backup - msg_info "Restoring data and configuration" - if [[ -d /opt/freshrss-backup/data ]]; then - cp -a /opt/freshrss-backup/data/. /opt/freshrss/data/ - fi - if [[ -d /opt/freshrss-backup/extensions ]]; then - cp -a /opt/freshrss-backup/extensions/. /opt/freshrss/extensions/ - fi - msg_ok "Data Restored" msg_info "Setting permissions" chown -R www-data:www-data /opt/freshrss @@ -66,9 +57,6 @@ function update_script() { systemctl start apache2 msg_ok "Started Apache2" - msg_info "Cleaning up backup" - rm -rf /opt/freshrss-backup - msg_ok "Cleaned up backup" msg_ok "Updated successfully!" fi exit diff --git a/ct/ghostfolio.sh b/ct/ghostfolio.sh index 919099faef0..70c0bdc1e5a 100644 --- a/ct/ghostfolio.sh +++ b/ct/ghostfolio.sh @@ -35,19 +35,12 @@ function update_script() { systemctl stop ghostfolio msg_ok "Stopped Service" - msg_info "Creating Backup" - tar -czf "/opt/ghostfolio_backup_$(date +%F).tar.gz" \ - -C /opt \ - --exclude="ghostfolio/node_modules" \ - --exclude="ghostfolio/dist" \ - ghostfolio - mv /opt/ghostfolio/.env /opt/env.backup - msg_ok "Backup Created" + create_backup /opt/ghostfolio/.env CLEAN_INSTALL=1 fetch_and_deploy_gh_release "ghostfolio" "ghostfolio/ghostfolio" "tarball" "latest" "/opt/ghostfolio" + restore_backup msg_info "Updating Ghostfolio" - mv /opt/env.backup /opt/ghostfolio/.env sed -i -E '/^DATABASE_URL=/ s/[?&]sslmode=prefer//g' /opt/ghostfolio/.env cd /opt/ghostfolio $STD npm ci diff --git a/ct/github-runner.sh b/ct/github-runner.sh index 245270c2060..38684da5531 100644 --- a/ct/github-runner.sh +++ b/ct/github-runner.sh @@ -38,22 +38,11 @@ function update_script() { systemctl stop actions-runner msg_ok "Stopped Service" - msg_info "Backing up runner configuration" - BACKUP_DIR="/opt/actions-runner.backup" - mkdir -p "$BACKUP_DIR" - for f in .runner .credentials .credentials_rsaparams .env .path; do - [[ -f /opt/actions-runner/$f ]] && cp -a /opt/actions-runner/$f "$BACKUP_DIR/" - done - msg_ok "Backed up configuration" + create_backup /opt/actions-runner/$f CLEAN_INSTALL=1 fetch_and_deploy_gh_release "actions-runner" "actions/runner" "prebuild" "latest" "/opt/actions-runner" "actions-runner-linux-x64-*.tar.gz" + restore_backup - msg_info "Restoring runner configuration" - for f in .runner .credentials .credentials_rsaparams .env .path; do - [[ -f "$BACKUP_DIR/$f" ]] && cp -a "$BACKUP_DIR/$f" /opt/actions-runner/ - done - rm -rf "$BACKUP_DIR" - msg_ok "Restored configuration" msg_info "Starting Service" systemctl start actions-runner diff --git a/ct/gogs.sh b/ct/gogs.sh index 6342738b257..f4bd37ef9ad 100644 --- a/ct/gogs.sh +++ b/ct/gogs.sh @@ -35,18 +35,11 @@ function update_script() { systemctl stop gogs msg_ok "Stopped Service" - msg_info "Backing up Data" - cp -r /opt/gogs/custom /opt/gogs_custom_backup - cp -r /opt/gogs/data /opt/gogs_data_backup - msg_ok "Backed up Data" + create_backup /opt/gogs/custom /opt/gogs/data CLEAN_INSTALL=1 fetch_and_deploy_gh_release "gogs" "gogs/gogs" "prebuild" "latest" "/opt/gogs" "gogs_*_linux_amd64.tar.gz" + restore_backup - msg_info "Restoring Data" - cp -r /opt/gogs_custom_backup/. /opt/gogs/custom - cp -r /opt/gogs_data_backup/. /opt/gogs/data - rm -rf /opt/gogs_custom_backup /opt/gogs_data_backup - msg_ok "Restored Data" msg_info "Starting Service" systemctl start gogs diff --git a/ct/healthchecks.sh b/ct/healthchecks.sh index b3704ca603e..98aac722840 100644 --- a/ct/healthchecks.sh +++ b/ct/healthchecks.sh @@ -35,12 +35,10 @@ function update_script() { systemctl stop healthchecks msg_ok "Stopped Services" - msg_info "Backing up existing installation" - BACKUP="/opt/healthchecks-backup-$(date +%F-%H%M)" - cp -a /opt/healthchecks "$BACKUP" - msg_ok "Backup created at $BACKUP" + create_backup /opt/healthchecks fetch_and_deploy_gh_release "healthchecks" "healthchecks/healthchecks" "tarball" + restore_backup cd /opt/healthchecks if [[ -d venv ]]; then diff --git a/ct/homelable.sh b/ct/homelable.sh index 8348cd52917..380a5d9f351 100644 --- a/ct/homelable.sh +++ b/ct/homelable.sh @@ -35,15 +35,10 @@ function update_script() { systemctl stop homelable msg_ok "Stopped Service" - msg_info "Backing up Configuration and Data" - cp /opt/homelable/backend/.env /opt/homelable.env.bak - cp -r /opt/homelable/data /opt/homelable_data_bak - if [[ -f /opt/homelable/mcp/.env ]]; then - cp -a /opt/homelable/mcp/.env /opt/homelable-mcp.env.bak - fi - msg_ok "Backed up Configuration and Data" + create_backup /opt/homelable/backend/.env /opt/homelable/data /opt/homelable/mcp/.env CLEAN_INSTALL=1 fetch_and_deploy_gh_release "homelable" "Pouzor/homelable" "tarball" "latest" "/opt/homelable" + restore_backup msg_info "Updating Python Dependencies" cd /opt/homelable/backend @@ -57,17 +52,9 @@ function update_script() { $STD npm run build msg_ok "Rebuilt Frontend" - msg_info "Restoring Configuration and Data" - cp /opt/homelable.env.bak /opt/homelable/backend/.env - cp -r /opt/homelable_data_bak/. /opt/homelable/data/ - rm -f /opt/homelable.env.bak - rm -rf /opt/homelable_data_bak - msg_ok "Restored Configuration and Data" - if [[ -f /opt/homelable-mcp.env.bak ]]; then + if [[ -f /opt/homelable/mcp/.env ]]; then msg_info "Restoring MCP Server" - cp -a /opt/homelable-mcp.env.bak /opt/homelable/mcp/.env - rm -f /opt/homelable-mcp.env.bak MCP_OWNER=$(stat -c '%U' /opt/homelable/mcp/.env) cd /opt/homelable/mcp $STD uv venv --clear /opt/homelable/mcp/.venv diff --git a/ct/homepage.sh b/ct/homepage.sh index eea6599de02..ed8d048f96a 100644 --- a/ct/homepage.sh +++ b/ct/homepage.sh @@ -37,20 +37,10 @@ function update_script() { systemctl stop homepage msg_ok "Stopped service" - msg_info "Creating Backup" - cp /opt/homepage/.env /opt/homepage.env - cp -r /opt/homepage/config /opt/homepage_config_backup - [[ -d /opt/homepage/public/images ]] && cp -r /opt/homepage/public/images /opt/homepage_images_backup - [[ -d /opt/homepage/public/icons ]] && cp -r /opt/homepage/public/icons /opt/homepage_icons_backup - msg_ok "Created Backup" - + create_backup /opt/homepage/.env /opt/homepage/config /opt/homepage/public/images /opt/homepage/public/icons + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "homepage" "gethomepage/homepage" "tarball" - - msg_info "Restoring Backup" - mv /opt/homepage.env /opt/homepage - rm -rf /opt/homepage/config - mv /opt/homepage_config_backup /opt/homepage/config - msg_ok "Restored Backup" + restore_backup msg_info "Updating Homepage (Patience)" RELEASE=$(get_latest_github_release "gethomepage/homepage") @@ -63,8 +53,6 @@ function update_script() { export NEXT_PUBLIC_BUILDTIME=$(curl -fsSL https://api.github.com/repos/gethomepage/homepage/releases/latest | jq -r '.published_at') export NEXT_TELEMETRY_DISABLED=1 $STD pnpm build - [[ -d /opt/homepage_images_backup ]] && mv /opt/homepage_images_backup /opt/homepage/public/images - [[ -d /opt/homepage_icons_backup ]] && mv /opt/homepage_icons_backup /opt/homepage/public/icons msg_ok "Updated Homepage" msg_info "Starting service" diff --git a/ct/hortusfox.sh b/ct/hortusfox.sh index e754255a0ff..d1ada3958a7 100644 --- a/ct/hortusfox.sh +++ b/ct/hortusfox.sh @@ -34,24 +34,19 @@ function update_script() { systemctl stop apache2 msg_ok "Stopped Service" - msg_info "Backing up current HortusFox installation" - cd /opt - mv /opt/hortusfox/ /opt/hortusfox-backup - msg_ok "Backed up current HortusFox installation" + create_backup /opt/hortusfox/.env /opt/hortusfox/public/img CLEAN_INSTALL=1 fetch_and_deploy_gh_release "hortusfox" "danielbrendel/hortusfox-web" "tarball" + restore_backup msg_info "Updating HortusFox" cd /opt/hortusfox - cp /opt/hortusfox-backup/.env /opt/hortusfox/.env - cp -a /opt/hortusfox-backup/public/img/. /opt/hortusfox/public/img/ export COMPOSER_ALLOW_SUPERUSER=1 $STD composer install --no-dev --optimize-autoloader $STD php asatru migrate:upgrade $STD php asatru plants:attributes $STD php asatru calendar:classes chown -R www-data:www-data /opt/hortusfox - rm -r /opt/hortusfox-backup msg_ok "Updated HortusFox" msg_info "Starting Service" diff --git a/ct/immichframe.sh b/ct/immichframe.sh index c4da9fe1e69..e8366cef02e 100644 --- a/ct/immichframe.sh +++ b/ct/immichframe.sh @@ -35,11 +35,10 @@ function update_script() { systemctl stop immichframe msg_ok "Stopped Service" - msg_info "Backing up Configuration" - cp -r /opt/immichframe/Config /tmp/immichframe_config.bak - msg_ok "Backed up Configuration" + create_backup /opt/immichframe/Config CLEAN_INSTALL=1 fetch_and_deploy_gh_release "immichframe" "immichFrame/ImmichFrame" "tarball" "latest" "/tmp/immichframe" + restore_backup msg_info "Setting up ImmichFrame" cd /tmp/immichframe @@ -57,11 +56,6 @@ function update_script() { rm -rf /tmp/immichframe msg_ok "Setup ImmichFrame" - msg_info "Restoring Configuration" - cp -r /tmp/immichframe_config.bak/* /opt/immichframe/Config/ - rm -rf /tmp/immichframe_config.bak - chown -R immichframe:immichframe /opt/immichframe - msg_ok "Restored Configuration" msg_info "Starting Service" diff --git a/ct/invoiceninja.sh b/ct/invoiceninja.sh index 79fcc250044..b362314b6b6 100644 --- a/ct/invoiceninja.sh +++ b/ct/invoiceninja.sh @@ -35,21 +35,14 @@ function update_script() { systemctl stop supervisor nginx php8.4-fpm msg_ok "Stopped Services" - msg_info "Creating Backup" - mkdir -p /tmp/invoiceninja_backup - cp /opt/invoiceninja/.env /tmp/invoiceninja_backup/ + create_backup /opt/invoiceninja/storage /opt/invoiceninja/public/storage cp -r /opt/invoiceninja/storage /tmp/invoiceninja_backup/ 2>/dev/null || true cp -r /opt/invoiceninja/public/storage /tmp/invoiceninja_backup/public_storage 2>/dev/null || true msg_ok "Created Backup" CLEAN_INSTALL=1 fetch_and_deploy_gh_release "invoiceninja" "invoiceninja/invoiceninja" "prebuild" "latest" "/opt/invoiceninja" "invoiceninja.tar.gz" + restore_backup - msg_info "Restoring Data" - cp /tmp/invoiceninja_backup/.env /opt/invoiceninja/ - cp -r /tmp/invoiceninja_backup/storage/* /opt/invoiceninja/storage/ 2>/dev/null || true - cp -r /tmp/invoiceninja_backup/public_storage/* /opt/invoiceninja/public/storage/ 2>/dev/null || true - rm -rf /tmp/invoiceninja_backup - msg_ok "Restored Data" msg_info "Running Migrations" cd /opt/invoiceninja diff --git a/ct/invoiceshelf.sh b/ct/invoiceshelf.sh index 15fa2c368e1..c613a4f97da 100644 --- a/ct/invoiceshelf.sh +++ b/ct/invoiceshelf.sh @@ -35,19 +35,11 @@ function update_script() { systemctl stop caddy msg_ok "Stopped Services" - msg_info "Backing up Data" - cp /opt/invoiceshelf/.env /opt/invoiceshelf.env.bak - cp -r /opt/invoiceshelf/storage /opt/invoiceshelf_storage_backup - msg_ok "Backed up Data" + create_backup /opt/invoiceshelf/storage CLEAN_INSTALL=1 fetch_and_deploy_gh_release "invoiceshelf" "InvoiceShelf/InvoiceShelf" "tarball" + restore_backup - msg_info "Restoring Data" - cp /opt/invoiceshelf.env.bak /opt/invoiceshelf/.env - rm -f /opt/invoiceshelf.env.bak - cp -r /opt/invoiceshelf_storage_backup/. /opt/invoiceshelf/storage - rm -rf /opt/invoiceshelf_storage_backup - msg_ok "Restored Data" msg_info "Updating Application" cd /opt/invoiceshelf diff --git a/ct/jotty.sh b/ct/jotty.sh index 74267afda2e..400d30d0cc3 100644 --- a/ct/jotty.sh +++ b/ct/jotty.sh @@ -35,20 +35,12 @@ function update_script() { systemctl stop jotty msg_ok "Stopped Service" - msg_info "Backing up configuration & data" - cp /opt/jotty/.env /opt/app.env - [[ -d /opt/jotty/data ]] && mv /opt/jotty/data /opt/data - [[ -d /opt/jotty/config ]] && mv /opt/jotty/config /opt/config - msg_ok "Backed up configuration & data" + create_backup /opt/jotty/data /opt/jotty/config NODE_VERSION="22" NODE_MODULE="yarn" setup_nodejs CLEAN_INSTALL=1 fetch_and_deploy_gh_release "jotty" "fccview/jotty" "prebuild" "latest" "/opt/jotty" "jotty_*_prebuild.tar.gz" + restore_backup - msg_info "Restoring configuration & data" - mv /opt/app.env /opt/jotty/.env - [[ -d /opt/data ]] && mv /opt/data /opt/jotty/data - [[ -d /opt/config ]] && cp -a /opt/config/* /opt/jotty/config && rm -rf /opt/config - msg_ok "Restored configuration & data" msg_info "Starting Service" systemctl start jotty diff --git a/ct/koel.sh b/ct/koel.sh index 6936266c68e..544d398c684 100644 --- a/ct/koel.sh +++ b/ct/koel.sh @@ -35,21 +35,14 @@ function update_script() { systemctl stop nginx php8.4-fpm msg_ok "Stopped Services" - msg_info "Creating Backup" - mkdir -p /tmp/koel_backup - cp /opt/koel/.env /tmp/koel_backup/ + create_backup /opt/koel/storage /opt/koel/public/img cp -r /opt/koel/storage /tmp/koel_backup/ 2>/dev/null || true cp -r /opt/koel/public/img /tmp/koel_backup/ 2>/dev/null || true msg_ok "Created Backup" CLEAN_INSTALL=1 fetch_and_deploy_gh_release "koel" "koel/koel" "prebuild" "latest" "/opt/koel" "koel-*.tar.gz" + restore_backup - msg_info "Restoring Data" - cp /tmp/koel_backup/.env /opt/koel/ - cp -r /tmp/koel_backup/storage/* /opt/koel/storage/ 2>/dev/null || true - cp -r /tmp/koel_backup/img/* /opt/koel/public/img/ 2>/dev/null || true - rm -rf /tmp/koel_backup - msg_ok "Restored Data" msg_info "Running Migrations" cd /opt/koel diff --git a/ct/leantime.sh b/ct/leantime.sh index 2a040407860..f582fbce03b 100644 --- a/ct/leantime.sh +++ b/ct/leantime.sh @@ -31,22 +31,13 @@ function update_script() { fi setup_mariadb if check_for_gh_release "leantime" "Leantime/leantime"; then - msg_info "Creating Backup" - mariadb-dump leantime >"/opt/leantime_db_backup_$(date +%F).sql" - tar -czf "/opt/leantime_backup_$(date +%F).tar.gz" "/opt/leantime" - mv /opt/leantime /opt/leantime_bak - msg_ok "Backup Created" + create_backup /opt/leantime fetch_and_deploy_gh_release "leantime" "Leantime/leantime" "prebuild" "latest" "/opt/leantime" Leantime*.tar.gz + restore_backup - msg_info "Restoring Config & Permissions" - mv /opt/leantime_bak/config/.env /opt/leantime/config/.env - chown -R www-data:www-data "/opt/leantime" - chmod -R 750 "/opt/leantime" - msg_ok "Restored Config & Permissions" msg_info "Removing Backup" - rm -rf /opt/leantime_bak msg_ok "Removed Backup" msg_ok "Updated successfully!" fi diff --git a/ct/linkding.sh b/ct/linkding.sh index 09119791e18..93aab1b4a67 100644 --- a/ct/linkding.sh +++ b/ct/linkding.sh @@ -35,19 +35,11 @@ function update_script() { systemctl stop nginx linkding linkding-tasks msg_ok "Stopped Services" - msg_info "Backing up Data" - cp -r /opt/linkding/data /opt/linkding_data_backup - cp /opt/linkding/.env /opt/linkding_env_backup - msg_ok "Backed up Data" + create_backup /opt/linkding/data CLEAN_INSTALL=1 fetch_and_deploy_gh_release "linkding" "sissbruecker/linkding" "tarball" + restore_backup - msg_info "Restoring Data" - cp -r /opt/linkding_data_backup/. /opt/linkding/data - cp /opt/linkding_env_backup /opt/linkding/.env - rm -rf /opt/linkding_data_backup /opt/linkding_env_backup - ln -sf /usr/lib/x86_64-linux-gnu/mod_icu.so /opt/linkding/libicu.so - msg_ok "Restored Data" msg_info "Updating LinkDing" cd /opt/linkding diff --git a/ct/linkwarden.sh b/ct/linkwarden.sh index 59eb32c048d..865be424438 100644 --- a/ct/linkwarden.sh +++ b/ct/linkwarden.sh @@ -35,13 +35,10 @@ function update_script() { RUST_CRATES="monolith" setup_rust - msg_info "Backing up data" - mv /opt/linkwarden/.env /opt/.env - [ -d /opt/linkwarden/data ] && mv /opt/linkwarden/data /opt/data.bak - rm -rf /opt/linkwarden - msg_ok "Backed up data" + create_backup /opt/linkwarden/.env /opt/linkwarden/data fetch_and_deploy_gh_release "linkwarden" "linkwarden/linkwarden" "tarball" + restore_backup msg_info "Updating Linkwarden" cd /opt/linkwarden @@ -60,11 +57,9 @@ function update_script() { $STD yarn $STD npx playwright install-deps $STD npx playwright install - mv /opt/.env /opt/linkwarden/.env $STD yarn prisma:generate $STD yarn web:build $STD yarn prisma:deploy - [ -d /opt/data.bak ] && mv /opt/data.bak /opt/linkwarden/data rm -rf ~/.cargo/registry ~/.cargo/git ~/.cargo/.package-cache rm -rf /root/.cache/yarn rm -rf /opt/linkwarden/.next/cache diff --git a/ct/listmonk.sh b/ct/listmonk.sh index 11483bf4649..e8661a69561 100644 --- a/ct/listmonk.sh +++ b/ct/listmonk.sh @@ -33,17 +33,13 @@ function update_script() { systemctl stop listmonk msg_ok "Stopped Service" - msg_info "Backing up data" - mv /opt/listmonk/ /opt/listmonk-backup - msg_ok "Backed up data" + create_backup /opt/listmonk/config.toml /opt/listmonk/uploads fetch_and_deploy_gh_release "listmonk" "knadh/listmonk" "prebuild" "latest" "/opt/listmonk" "listmonk*linux_amd64.tar.gz" + restore_backup msg_info "Configuring listmonk" - mv /opt/listmonk-backup/config.toml /opt/listmonk/config.toml - mv /opt/listmonk-backup/uploads /opt/listmonk/uploads $STD /opt/listmonk/listmonk --upgrade --yes --config /opt/listmonk/config.toml - rm -rf /opt/listmonk-backup/ msg_ok "Configured listmonk" msg_info "Starting Service" diff --git a/ct/lubelogger.sh b/ct/lubelogger.sh index ad8864379b6..78b7c364a72 100644 --- a/ct/lubelogger.sh +++ b/ct/lubelogger.sh @@ -33,23 +33,10 @@ function update_script() { systemctl stop lubelogger msg_ok "Stopped Service" - msg_info "Backing up data" - mkdir -p /tmp/lubeloggerData/data - cp /opt/lubelogger/appsettings.json /tmp/lubeloggerData/appsettings.json - cp -r /opt/lubelogger/data/ /tmp/lubeloggerData/ - - # Lubelogger has moved multiples folders to the 'data' folder, and we need to move them before the update to keep the user data - # Github Discussion: https://github.com/hargata/lubelog/discussions/787 - [[ -e /opt/lubelogger/config ]] && cp -r /opt/lubelogger/config /tmp/lubeloggerData/data/ - [[ -e /opt/lubelogger/wwwroot/translations ]] && cp -r /opt/lubelogger/wwwroot/translations /tmp/lubeloggerData/data/ - [[ -e /opt/lubelogger/wwwroot/documents ]] && cp -r /opt/lubelogger/wwwroot/documents /tmp/lubeloggerData/data/ - [[ -e /opt/lubelogger/wwwroot/images ]] && cp -r /opt/lubelogger/wwwroot/images /tmp/lubeloggerData/data/ - [[ -e /opt/lubelogger/wwwroot/temp ]] && cp -r /opt/lubelogger/wwwroot/temp /tmp/lubeloggerData/data/ - [[ -e /opt/lubelogger/log ]] && cp -r /opt/lubelogger/log /tmp/lubeloggerData/ - rm -rf /opt/lubelogger - msg_ok "Backed up data" + create_backup /opt/lubelogger/data/ fetch_and_deploy_gh_release "lubelogger" "hargata/lubelog" "prebuild" "latest" "/opt/lubelogger" "LubeLogger*linux_x64.zip" + restore_backup msg_info "Configuring LubeLogger" chmod 700 /opt/lubelogger/CarCareTracker diff --git a/ct/lychee.sh b/ct/lychee.sh index e5d63029090..487ed9fae02 100644 --- a/ct/lychee.sh +++ b/ct/lychee.sh @@ -35,19 +35,11 @@ function update_script() { systemctl stop caddy msg_ok "Stopped Services" - msg_info "Backing up Data" - cp /opt/lychee/.env /opt/lychee.env.bak - cp -r /opt/lychee/storage /opt/lychee_storage_backup - msg_ok "Backed up Data" + create_backup /opt/lychee/storage CLEAN_INSTALL=1 fetch_and_deploy_gh_release "lychee" "LycheeOrg/Lychee" "prebuild" "latest" "/opt/lychee" "Lychee.zip" + restore_backup - msg_info "Restoring Data" - cp /opt/lychee.env.bak /opt/lychee/.env - rm -f /opt/lychee.env.bak - cp -r /opt/lychee_storage_backup/. /opt/lychee/storage - rm -rf /opt/lychee_storage_backup - msg_ok "Restored Data" msg_info "Updating Application" cd /opt/lychee diff --git a/ct/mafl.sh b/ct/mafl.sh index 22807df7c23..b432b3c4757 100644 --- a/ct/mafl.sh +++ b/ct/mafl.sh @@ -33,19 +33,15 @@ function update_script() { systemctl stop mafl msg_ok "Service stopped" - msg_info "Backing up data" - mkdir -p /opt/mafl-backup/data - mv /opt/mafl/data /opt/mafl-backup/data - rm -rf /opt/mafl - msg_ok "Backup complete" + create_backup /opt/mafl/data - fetch_and_deploy_gh_release "mafl" "hywax/mafl" "tarball" + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "mafl" "hywax/mafl" "tarball" + restore_backup msg_info "Updating Mafl" cd /opt/mafl $STD yarn install $STD yarn build - mv /opt/mafl-backup/data /opt/mafl/data msg_ok "Mafl updated" msg_info "Starting Service" diff --git a/ct/magicmirror.sh b/ct/magicmirror.sh index ad5f92787ac..80f013b82a1 100644 --- a/ct/magicmirror.sh +++ b/ct/magicmirror.sh @@ -35,26 +35,15 @@ function update_script() { NODE_VERSION="24" setup_nodejs - msg_info "Backing up data" - rm -rf /opt/magicmirror-backup - mkdir /opt/magicmirror-backup - cp /opt/magicmirror/config/config.js /opt/magicmirror-backup - if [[ -f /opt/magicmirror/css/custom.css ]]; then - cp /opt/magicmirror/css/custom.css /opt/magicmirror-backup - fi - cp -r /opt/magicmirror/modules /opt/magicmirror-backup - msg_ok "Backed up data" + create_backup /opt/magicmirror/config/config.js /opt/magicmirror/css/custom.css /opt/magicmirror/modules fetch_and_deploy_gh_release "magicmirror" "MagicMirrorOrg/MagicMirror" "tarball" + restore_backup msg_info "Configuring MagicMirror" cd /opt/magicmirror sed -i -E 's/("postinstall": )".*"/\1""/; s/("prepare": )".*"/\1""/' package.json $STD npm run install-mm - cp /opt/magicmirror-backup/config.js /opt/magicmirror/config/ - if [[ -f /opt/magicmirror-backup/custom.css ]]; then - cp /opt/magicmirror-backup/custom.css /opt/magicmirror/css/ - fi msg_ok "Configured MagicMirror" msg_info "Starting Service" diff --git a/ct/mail-archiver.sh b/ct/mail-archiver.sh index 366d367a6db..ef4bdc29d68 100644 --- a/ct/mail-archiver.sh +++ b/ct/mail-archiver.sh @@ -36,12 +36,11 @@ function update_script() { systemctl stop mail-archiver msg_ok "Stopped Mail-Archiver" - msg_info "Creating Backup" - cp /opt/mail-archiver/appsettings.json /opt/mail-archiver/.env /opt/ - [[ -d /opt/mail-archiver/DataProtection-Keys ]] && cp -r /opt/mail-archiver/DataProtection-Keys /opt + create_backup /opt/mail-archiver/DataProtection-Keys msg_ok "Created Backup" CLEAN_INSTALL=1 fetch_and_deploy_gh_release "mail-archiver" "s1t5/mail-archiver" "tarball" + restore_backup msg_info "Updating Mail-Archiver" mv /opt/mail-archiver /opt/mail-archiver-build @@ -51,10 +50,6 @@ function update_script() { rm -rf /opt/mail-archiver-build msg_ok "Updated Mail-Archiver" - msg_info "Restoring Backup" - cp /opt/appsettings.json /opt/.env /opt/mail-archiver - [[ -d /opt/DataProtection-Keys ]] && cp -r /opt/DataProtection-Keys /opt/mail-archiver/ - msg_ok "Restored Backup" msg_info "Starting Mail-Archiver" systemctl start mail-archiver diff --git a/ct/manyfold.sh b/ct/manyfold.sh index 86e1022ddca..63bef42d063 100644 --- a/ct/manyfold.sh +++ b/ct/manyfold.sh @@ -37,14 +37,10 @@ function update_script() { systemctl stop manyfold.target manyfold-rails.1 manyfold-default_worker.1 manyfold-performance_worker.1 msg_ok "Stopped Services" - msg_info "Backing up Data" - CURRENT_VERSION=$(grep -oP 'APP_VERSION=\K[^ ]+' /opt/manyfold/.env || echo "unknown") - cp -r /opt/manyfold/app/storage /opt/manyfold_storage_backup 2>/dev/null || true - cp -r /opt/manyfold/app/tmp /opt/manyfold_tmp_backup 2>/dev/null || true - $STD tar -czf "/opt/manyfold_${CURRENT_VERSION}_backup.tar.gz" -C /opt/manyfold app - msg_ok "Backed up Data" + create_backup /opt/manyfold/app/storage /opt/manyfold/app/tmp CLEAN_INSTALL=1 fetch_and_deploy_gh_release "manyfold" "manyfold3d/manyfold" "tarball" "latest" "/opt/manyfold/app" + restore_backup msg_info "Configuring Manyfold" RUBY_INSTALL_VERSION=$(cat /opt/manyfold/app/.ruby-version) @@ -55,14 +51,6 @@ function update_script() { RUBY_VERSION=${RUBY_INSTALL_VERSION} RUBY_INSTALL_RAILS="true" HOME=/home/manyfold setup_ruby - msg_info "Restoring Data" - rm -rf /opt/manyfold/app/{storage,tmp} - cp -r /opt/manyfold_storage_backup /opt/manyfold/app/storage 2>/dev/null || true - cp -r /opt/manyfold_tmp_backup /opt/manyfold/app/tmp 2>/dev/null || true - chown -R manyfold:manyfold {/home/manyfold,/opt/manyfold} - chown -R manyfold:manyfold /opt/manyfold/app/storage /opt/manyfold/app/tmp /opt/manyfold/app/config - rm -rf /opt/manyfold_storage_backup /opt/manyfold_tmp_backup - msg_ok "Restored Data" msg_info "Installing Manyfold" $STD npm install --global corepack diff --git a/ct/matomo.sh b/ct/matomo.sh index a753daf683a..a68431a2042 100644 --- a/ct/matomo.sh +++ b/ct/matomo.sh @@ -35,28 +35,11 @@ function update_script() { systemctl stop caddy msg_ok "Stopped Services" - msg_info "Backing up Data" - [[ -f /opt/matomo/config/config.ini.php ]] && cp /opt/matomo/config/config.ini.php /opt/matomo_config.bak - [[ -d /opt/matomo/misc/user ]] && cp -r /opt/matomo/misc/user /opt/matomo_user_backup - [[ -f /root/matomo.creds ]] && cp /root/matomo.creds /opt/matomo_db_creds.bak - msg_ok "Backed up Data" + create_backup /opt/matomo/misc/user CLEAN_INSTALL=1 fetch_and_deploy_gh_release "matomo" "matomo-org/matomo" "prebuild" "latest" "/opt/matomo" "matomo-*.zip" + restore_backup - msg_info "Restoring Data" - if [[ -f /opt/matomo_config.bak ]]; then - mkdir -p /opt/matomo/config - cp /opt/matomo_config.bak /opt/matomo/config/config.ini.php - fi - if [[ -d /opt/matomo_user_backup ]]; then - mkdir -p /opt/matomo/misc/user - cp -r /opt/matomo_user_backup/. /opt/matomo/misc/user - fi - [[ -f /opt/matomo_db_creds.bak ]] && cp /opt/matomo_db_creds.bak /root/matomo.creds - rm -f /opt/matomo_config.bak /opt/matomo_db_creds.bak - rm -rf /opt/matomo_user_backup - chown -R www-data:www-data /opt/matomo - msg_ok "Restored Data" msg_info "Starting Services" systemctl start caddy diff --git a/ct/mealie.sh b/ct/mealie.sh index 1f3631ccc95..29f359adf3a 100644 --- a/ct/mealie.sh +++ b/ct/mealie.sh @@ -37,12 +37,11 @@ function update_script() { systemctl stop mealie msg_ok "Stopped Service" - msg_info "Backing up Configuration" - cp -f /opt/mealie/mealie.env /opt/mealie.env - [[ -f /opt/mealie/start.sh ]] && cp -f /opt/mealie/start.sh /opt/mealie.start.sh + create_backup /opt/mealie/mealie.env /opt/mealie/start.sh msg_ok "Backup completed" CLEAN_INSTALL=1 fetch_and_deploy_gh_release "mealie" "mealie-recipes/mealie" "tarball" + restore_backup msg_info "Restoring Configuration" mv -f /opt/mealie.env /opt/mealie/mealie.env diff --git a/ct/metube.sh b/ct/metube.sh index fbaeee46c20..bbb62c19046 100644 --- a/ct/metube.sh +++ b/ct/metube.sh @@ -48,14 +48,10 @@ function update_script() { systemctl stop metube msg_ok "Stopped Service" - msg_info "Backing up Old Installation" - if [[ -d /opt/metube_bak ]]; then - rm -rf /opt/metube_bak - fi - mv /opt/metube /opt/metube_bak - msg_ok "Backup created" + create_backup /opt/metube fetch_and_deploy_gh_release "metube" "alexta69/metube" "tarball" "latest" + restore_backup msg_info "Building Frontend" cd /opt/metube/ui @@ -75,12 +71,6 @@ function update_script() { $STD uv sync msg_ok "Installed Backend" - msg_info "Restoring .env" - if [[ -f /opt/metube_bak/.env ]]; then - cp /opt/metube_bak/.env /opt/metube/.env - fi - rm -rf /opt/metube_bak - msg_ok "Restored .env" if grep -q 'pipenv' /etc/systemd/system/metube.service; then msg_info "Patching systemd Service" diff --git a/ct/musicseerr.sh b/ct/musicseerr.sh index a20484fb820..24f73904108 100644 --- a/ct/musicseerr.sh +++ b/ct/musicseerr.sh @@ -35,13 +35,11 @@ function update_script() { systemctl stop musicseerr msg_ok "Stopped Service" - msg_info "Backing up Data" - cp -a /opt/musicseerr/backend/config /opt/musicseerr_config_backup - cp -a /opt/musicseerr/backend/cache /opt/musicseerr_cache_backup - msg_ok "Backed up Data" + create_backup /opt/musicseerr/backend/config /opt/musicseerr/backend/cache PYTHON_VERSION="3.13" setup_uv CLEAN_INSTALL=1 fetch_and_deploy_gh_release "musicseerr" "HabiRabbu/Musicseerr" "tarball" + restore_backup NODE_VERSION="25" NODE_MODULE="pnpm@10.33.0" setup_nodejs msg_info "Building Frontend" @@ -60,12 +58,6 @@ function update_script() { cp -r /opt/musicseerr/frontend/build /opt/musicseerr/backend/static msg_ok "Updated Application" - msg_info "Restoring Data" - rm -rf /opt/musicseerr/backend/config /opt/musicseerr/backend/cache - cp -a /opt/musicseerr_config_backup/. /opt/musicseerr/backend/config/ - cp -a /opt/musicseerr_cache_backup/. /opt/musicseerr/backend/cache/ - rm -rf /opt/musicseerr_config_backup /opt/musicseerr_cache_backup - msg_ok "Restored Data" msg_info "Starting Service" systemctl start musicseerr diff --git a/ct/nagios.sh b/ct/nagios.sh index a73a55fe50e..26d9b7932c1 100644 --- a/ct/nagios.sh +++ b/ct/nagios.sh @@ -30,9 +30,7 @@ function update_script() { exit fi - msg_info "Backing up Configuration" - cp -a /usr/local/nagios/etc /opt/nagios-etc-backup - msg_ok "Backed up Configuration" + create_backup /usr/local/nagios/etc if check_for_gh_release "nagios" "NagiosEnterprises/nagioscore"; then msg_info "Stopping Nagios" @@ -40,6 +38,7 @@ function update_script() { msg_ok "Stopped Nagios" CLEAN_INSTALL=1 fetch_and_deploy_gh_release "nagios" "NagiosEnterprises/nagioscore" "tarball" + restore_backup msg_info "Building Nagios Core" cd /opt/nagios @@ -73,11 +72,6 @@ function update_script() { msg_ok "Built Nagios Plugins" fi - msg_info "Restoring Configuration" - rm -rf /usr/local/nagios/etc - cp -a /opt/nagios-etc-backup /usr/local/nagios/etc - rm -rf /opt/nagios-etc-backup - msg_ok "Restored Configuration" msg_ok "Updated successfully!" exit } diff --git a/ct/nametag.sh b/ct/nametag.sh index 0fd45d87780..360851ad2cc 100644 --- a/ct/nametag.sh +++ b/ct/nametag.sh @@ -35,12 +35,10 @@ function update_script() { systemctl stop nametag msg_ok "Stopped Service" - msg_info "Backing up Data" - cp /opt/nametag/.env /opt/nametag.env.bak - cp -r /opt/nametag/data /opt/nametag_data_bak - msg_ok "Backed up Data" + create_backup /opt/nametag/data CLEAN_INSTALL=1 fetch_and_deploy_gh_release "nametag" "mattogodoy/nametag" "tarball" "latest" "/opt/nametag" + restore_backup msg_info "Rebuilding Application" cd /opt/nametag @@ -54,12 +52,6 @@ function update_script() { cp -r /opt/nametag/public /opt/nametag/.next/standalone/public msg_ok "Rebuilt Application" - msg_info "Restoring Data" - cp /opt/nametag.env.bak /opt/nametag/.env - cp -r /opt/nametag_data_bak/. /opt/nametag/data/ - rm -f /opt/nametag.env.bak - rm -rf /opt/nametag_data_bak - msg_ok "Restored Data" msg_info "Running Migrations" cd /opt/nametag diff --git a/ct/netbox.sh b/ct/netbox.sh index 8f58ee09478..d8b90189832 100644 --- a/ct/netbox.sh +++ b/ct/netbox.sh @@ -34,20 +34,15 @@ function update_script() { systemctl stop netbox netbox-rq msg_ok "Stopped Services" - msg_info "Backing up NetBox configurations" - mv /opt/netbox/ /opt/netbox-backup - msg_ok "Backed up NetBox configurations" + create_backup /opt/netbox/netbox/netbox/configuration.py \ + /opt/netbox/netbox/media /opt/netbox/netbox/scripts /opt/netbox/netbox/reports \ + /opt/netbox/gunicorn.py /opt/netbox/local_requirements.txt \ + /opt/netbox/netbox/netbox/ldap_config.py CLEAN_INSTALL=1 fetch_and_deploy_gh_release "netbox" "netbox-community/netbox" "tarball" - - cp -r /opt/netbox-backup/netbox/netbox/configuration.py /opt/netbox/netbox/netbox/ - cp -r /opt/netbox-backup/netbox/{media,scripts,reports}/ /opt/netbox/netbox/ - cp -r /opt/netbox-backup/gunicorn.py /opt/netbox/ - [[ -f /opt/netbox-backup/local_requirements.txt ]] && cp -r /opt/netbox-backup/local_requirements.txt /opt/netbox/ - [[ -f /opt/netbox-backup/netbox/netbox/ldap_config.py ]] && cp -r /opt/netbox-backup/netbox/netbox/ldap_config.py /opt/netbox/netbox/netbox/ + restore_backup $STD /opt/netbox/upgrade.sh - rm -r /opt/netbox-backup msg_info "Starting Services" systemctl start netbox netbox-rq diff --git a/ct/ownfoil.sh b/ct/ownfoil.sh index 8c78d9ece7c..244489a9515 100644 --- a/ct/ownfoil.sh +++ b/ct/ownfoil.sh @@ -35,11 +35,10 @@ function update_script() { systemctl stop ownfoil msg_ok "Stopped Service" - msg_info "Backing up Data" - cp -r /opt/ownfoil/app/config /opt/ownfoil_data_backup - msg_ok "Backed up Data" + create_backup /opt/ownfoil/app/config CLEAN_INSTALL=1 fetch_and_deploy_gh_release "ownfoil" "a1ex4/ownfoil" "tarball" + restore_backup msg_info "Installing Dependencies" cd /opt/ownfoil @@ -47,10 +46,6 @@ function update_script() { $STD uv pip install -r requirements.txt msg_ok "Installed Dependencies" - msg_info "Restoring Data" - cp -r /opt/ownfoil_data_backup /opt/ownfoil/app/config - rm -rf /opt/ownfoil_data_backup - msg_ok "Restored Data" msg_info "Starting Service" systemctl start ownfoil diff --git a/ct/pangolin.sh b/ct/pangolin.sh index 0ea3d7bc007..9ea732b6fdc 100644 --- a/ct/pangolin.sh +++ b/ct/pangolin.sh @@ -41,15 +41,10 @@ function update_script() { systemctl stop gerbil msg_info "Service stopped" - msg_info "Creating backup" - tar -czf /opt/pangolin_config_backup.tar.gz -C /opt/pangolin config - if [[ -f /opt/pangolin/config/db/db.sqlite ]]; then - cp -a /opt/pangolin/config/db/db.sqlite \ - "/opt/pangolin/config/db/db.sqlite.pre-${PANGOLIN_VERSION}-$(date +%Y%m%d-%H%M%S).bak" - fi - msg_ok "Created backup" + create_backup /opt/pangolin/config CLEAN_INSTALL=1 fetch_and_deploy_gh_release "pangolin" "fosrl/pangolin" "tarball" "$PANGOLIN_VERSION" + restore_backup CLEAN_INSTALL=1 fetch_and_deploy_gh_release "gerbil" "fosrl/gerbil" "singlefile" "latest" "/usr/bin" "gerbil_linux_amd64" msg_info "Updating Pangolin" @@ -68,10 +63,6 @@ function update_script() { cp server/db/mac_models.json ./dist/mac_models.json msg_ok "Updated Pangolin" - msg_info "Restoring config" - tar -xzf /opt/pangolin_config_backup.tar.gz -C /opt/pangolin --overwrite - rm -f /opt/pangolin_config_backup.tar.gz - msg_ok "Restored config" if ! grep -q '^ExecStartPre=/usr/bin/node dist/migrations.mjs' /etc/systemd/system/pangolin.service 2>/dev/null; then msg_info "Adding migration step to pangolin.service" diff --git a/ct/paperless-ai.sh b/ct/paperless-ai.sh index 8c876a7f7a4..75c98076efb 100644 --- a/ct/paperless-ai.sh +++ b/ct/paperless-ai.sh @@ -34,16 +34,11 @@ function update_script() { systemctl stop paperless-ai paperless-rag msg_ok "Stopped Service" - msg_info "Backing up data" - cp -r /opt/paperless-ai/data /opt/paperless-ai-data-backup - msg_ok "Backed up data" + create_backup /opt/paperless-ai/data fetch_and_deploy_gh_release "paperless-ai" "clusterzx/paperless-ai" "tarball" + restore_backup - msg_info "Restoring data" - cp -r /opt/paperless-ai-data-backup/* /opt/paperless-ai/data/ - rm -rf /opt/paperless-ai-data-backup - msg_ok "Restored data" msg_info "Updating Paperless-AI" cd /opt/paperless-ai diff --git a/ct/pocketid.sh b/ct/pocketid.sh index baa2a672386..0fd775a691d 100755 --- a/ct/pocketid.sh +++ b/ct/pocketid.sh @@ -68,11 +68,12 @@ function update_script() { msg_info "Stopping Service" systemctl stop pocketid msg_ok "Stopped Service" - cp /opt/pocket-id/.env /opt/env fi + create_backup /opt/pocket-id/.env + fetch_and_deploy_gh_release "pocket-id" "pocket-id/pocket-id" "singlefile" "latest" "/opt/pocket-id/" "pocket-id-linux-amd64" - mv /opt/env /opt/pocket-id/.env + restore_backup msg_info "Starting Service" systemctl start pocketid diff --git a/ct/privatebin.sh b/ct/privatebin.sh index 9549837d9f9..baf768d6bd9 100644 --- a/ct/privatebin.sh +++ b/ct/privatebin.sh @@ -29,16 +29,14 @@ function update_script() { exit fi if check_for_gh_release "privatebin" "PrivateBin/PrivateBin"; then - msg_info "Creating backup" - cp -f /opt/privatebin/cfg/conf.php /tmp/privatebin_conf.bak - msg_ok "Backup created" + create_backup /opt/privatebin/cfg/conf.php rm -rf /opt/privatebin/* fetch_and_deploy_gh_release "privatebin" "PrivateBin/PrivateBin" "tarball" + restore_backup msg_info "Configuring ${APP}" mkdir -p /opt/privatebin/data - mv /tmp/privatebin_conf.bak /opt/privatebin/cfg/conf.php chown -R www-data:www-data /opt/privatebin chmod -R 0755 /opt/privatebin/data systemctl reload nginx php8.2-fpm diff --git a/ct/shlink.sh b/ct/shlink.sh index 1f6d1cf4c12..b96d066d31c 100644 --- a/ct/shlink.sh +++ b/ct/shlink.sh @@ -35,19 +35,11 @@ function update_script() { systemctl stop shlink msg_ok "Stopped Service" - msg_info "Backing up Data" - cp /opt/shlink/.env /opt/shlink.env.bak - cp -r /opt/shlink/data /opt/shlink_data_backup - msg_ok "Backed up Data" + create_backup /opt/shlink/data CLEAN_INSTALL=1 fetch_and_deploy_gh_release "shlink" "shlinkio/shlink" "prebuild" "latest" "/opt/shlink" "shlink*_php8.5_dist.zip" + restore_backup - msg_info "Restoring Data" - cp /opt/shlink.env.bak /opt/shlink/.env - rm -f /opt/shlink.env.bak - cp -r /opt/shlink_data_backup/. /opt/shlink/data - rm -rf /opt/shlink_data_backup - msg_ok "Restored Data" msg_info "Updating Application" cd /opt/shlink diff --git a/ct/snipeit.sh b/ct/snipeit.sh index 6ec4f4bd471..f97eb631ec1 100644 --- a/ct/snipeit.sh +++ b/ct/snipeit.sh @@ -38,11 +38,10 @@ function update_script() { systemctl stop nginx msg_ok "Services Stopped" - msg_info "Creating Backup" - mv /opt/snipe-it /opt/snipe-it-backup - msg_ok "Created Backup" + create_backup /opt/snipe-it/.env /opt/snipe-it/public/uploads /opt/snipe-it/storage/private_uploads fetch_and_deploy_gh_release "snipe-it" "grokability/snipe-it" "tarball" + restore_backup [[ "$(php -v 2>/dev/null)" == PHP\ 8.2* ]] && PHP_VERSION="8.3" PHP_FPM="YES" PHP_MODULE="ldap,soap,xsl" setup_php sed -i 's/php8.2/php8.3/g' /etc/nginx/conf.d/snipeit.conf setup_composer @@ -50,9 +49,6 @@ function update_script() { msg_info "Updating Snipe-IT" $STD apt update $STD apt -y upgrade - cp /opt/snipe-it-backup/.env /opt/snipe-it/.env - cp -r /opt/snipe-it-backup/public/uploads/. /opt/snipe-it/public/uploads/ - cp -r /opt/snipe-it-backup/storage/private_uploads/. /opt/snipe-it/storage/private_uploads/ cd /opt/snipe-it/ export COMPOSER_ALLOW_SUPERUSER=1 $STD composer install --no-dev --optimize-autoloader --no-interaction @@ -64,7 +60,6 @@ function update_script() { $STD php artisan view:clear chown -R www-data: /opt/snipe-it chmod -R 755 /opt/snipe-it - rm -rf /opt/snipe-it-backup msg_ok "Updated Snipe-IT" msg_info "Starting Service" diff --git a/ct/solidtime.sh b/ct/solidtime.sh index 98dddff8036..076371f5af0 100644 --- a/ct/solidtime.sh +++ b/ct/solidtime.sh @@ -35,19 +35,11 @@ function update_script() { systemctl stop caddy msg_ok "Stopped Services" - msg_info "Backing up Data" - cp /opt/solidtime/.env /opt/solidtime.env.bak - cp -r /opt/solidtime/storage /opt/solidtime_storage_backup - msg_ok "Backed up Data" + create_backup /opt/solidtime/storage CLEAN_INSTALL=1 fetch_and_deploy_gh_release "solidtime" "solidtime-io/solidtime" "tarball" + restore_backup - msg_info "Restoring Data" - cp /opt/solidtime.env.bak /opt/solidtime/.env - rm -f /opt/solidtime.env.bak - cp -r /opt/solidtime_storage_backup/. /opt/solidtime/storage - rm -rf /opt/solidtime_storage_backup - msg_ok "Restored Data" msg_info "Updating Application" cd /opt/solidtime diff --git a/ct/soulsync.sh b/ct/soulsync.sh index 0bd6c3c9f25..82e98946906 100644 --- a/ct/soulsync.sh +++ b/ct/soulsync.sh @@ -37,12 +37,10 @@ function update_script() { systemctl stop soulsync msg_ok "Stopped Service" - msg_info "Backing up Data" - mv /opt/soulsync/config /opt/soulsync-config.bak - mv /opt/soulsync/data /opt/soulsync-data.bak - msg_ok "Backed up Data" + create_backup /opt/soulsync/config /opt/soulsync/data CLEAN_INSTALL=1 fetch_and_deploy_gh_release "soulsync" "Nezreka/SoulSync" "tarball" + restore_backup msg_info "Updating Python Dependencies" cd /opt/soulsync @@ -56,9 +54,6 @@ function update_script() { $STD npm run build msg_ok "Built WebUI" - mv /opt/soulsync-config.bak /opt/soulsync/config - mv /opt/soulsync-data.bak /opt/soulsync/data - msg_info "Starting Service" systemctl start soulsync msg_ok "Started Service" diff --git a/ct/sparkyfitness.sh b/ct/sparkyfitness.sh index 5954b0bee40..7f2113f75ef 100644 --- a/ct/sparkyfitness.sh +++ b/ct/sparkyfitness.sh @@ -35,17 +35,10 @@ function update_script() { systemctl stop sparkyfitness-server nginx msg_ok "Stopped Services" - msg_info "Backing up data" - mkdir -p /opt/sparkyfitness_backup - if [[ -d /opt/sparkyfitness/SparkyFitnessServer/uploads ]]; then - cp -r /opt/sparkyfitness/SparkyFitnessServer/uploads /opt/sparkyfitness_backup/ - fi - if [[ -d /opt/sparkyfitness/SparkyFitnessServer/backup ]]; then - cp -r /opt/sparkyfitness/SparkyFitnessServer/backup /opt/sparkyfitness_backup/ - fi - msg_ok "Backed up data" + create_backup /opt/sparkyfitness/SparkyFitnessServer/uploads CLEAN_INSTALL=1 fetch_and_deploy_gh_release "sparkyfitness" "CodeWithCJ/SparkyFitness" "tarball" + restore_backup PNPM_VERSION="$(jq -r '.packageManager | split("@")[1]' /opt/sparkyfitness/package.json)" NODE_VERSION="25" NODE_MODULE="pnpm@${PNPM_VERSION}" setup_nodejs @@ -96,10 +89,6 @@ EOF systemctl daemon-reload msg_ok "Refreshed SparkyFitness Service" - msg_info "Restoring data" - cp -r /opt/sparkyfitness_backup/. /opt/sparkyfitness/SparkyFitnessServer/ - rm -rf /opt/sparkyfitness_backup - msg_ok "Restored data" msg_info "Starting Services" $STD systemctl start sparkyfitness-server nginx diff --git a/ct/spoolman.sh b/ct/spoolman.sh index c3c1a02b471..4fa874548ce 100644 --- a/ct/spoolman.sh +++ b/ct/spoolman.sh @@ -36,12 +36,11 @@ function update_script() { systemctl stop spoolman msg_ok "Stopped Service" - msg_info "Creating Backup" - [ -d /opt/spoolman_bak ] && rm -rf /opt/spoolman_bak - mv /opt/spoolman /opt/spoolman_bak + create_backup /opt/spoolman msg_ok "Created Backup" fetch_and_deploy_gh_release "spoolman" "Donkie/Spoolman" "prebuild" "latest" "/opt/spoolman" "spoolman.zip" + restore_backup msg_info "Updating Spoolman" cd /opt/spoolman diff --git a/ct/tandoor.sh b/ct/tandoor.sh index 57523303588..be75496dd86 100644 --- a/ct/tandoor.sh +++ b/ct/tandoor.sh @@ -43,17 +43,14 @@ function update_script() { systemctl stop tandoor msg_ok "Stopped Service" - msg_info "Creating Backup" - mv /opt/tandoor /opt/tandoor.bak - msg_ok "Backup Created" + create_backup /opt/tandoor/config /opt/tandoor/api /opt/tandoor/mediafiles /opt/tandoor/staticfiles /opt/tandoor/.env NODE_VERSION="22" NODE_MODULE="yarn" setup_nodejs PYTHON_VERSION="3.13" setup_uv fetch_and_deploy_gh_release "tandoor" "TandoorRecipes/recipes" "tarball" "latest" "/opt/tandoor" + restore_backup msg_info "Updating Tandoor" - cp -r /opt/tandoor.bak/{config,api,mediafiles,staticfiles} /opt/tandoor/ - mv /opt/tandoor.bak/.env /opt/tandoor/.env cd /opt/tandoor $STD uv venv --clear .venv --python=python3 $STD uv pip install -r requirements.txt --python .venv/bin/python @@ -69,7 +66,6 @@ EOF cd /opt/tandoor $STD /opt/tandoor/.venv/bin/python manage.py migrate $STD /opt/tandoor/.venv/bin/python manage.py collectstatic --no-input - rm -rf /opt/tandoor.bak msg_ok "Updated Tandoor" msg_info "Starting Service" diff --git a/ct/termix.sh b/ct/termix.sh index 4476c8d5a9d..d254fb7afa7 100644 --- a/ct/termix.sh +++ b/ct/termix.sh @@ -143,12 +143,10 @@ EOF fi msg_ok "Migrated Configuration" - msg_info "Backing up Data" - cp -r /opt/termix/data /opt/termix_data_backup - cp -r /opt/termix/uploads /opt/termix_uploads_backup - msg_ok "Backed up Data" + create_backup /opt/termix/data /opt/termix/uploads CLEAN_INSTALL=1 fetch_and_deploy_gh_release "termix" "Termix-SSH/Termix" "tarball" + restore_backup msg_info "Recreating Directories" mkdir -p /opt/termix/html \ @@ -177,11 +175,6 @@ EOF $STD npm cache clean --force msg_ok "Set up Production Dependencies" - msg_info "Restoring Data" - cp -r /opt/termix_data_backup /opt/termix/data - cp -r /opt/termix_uploads_backup /opt/termix/uploads - rm -rf /opt/termix_data_backup /opt/termix_uploads_backup - msg_ok "Restored Data" msg_info "Updating Frontend Files" rm -rf /opt/termix/html/* diff --git a/ct/tianji.sh b/ct/tianji.sh index 3bc530ff8d1..6883994bce6 100644 --- a/ct/tianji.sh +++ b/ct/tianji.sh @@ -36,12 +36,10 @@ function update_script() { systemctl stop tianji msg_ok "Stopped Service" - msg_info "Backing up data" - cp /opt/tianji/src/server/.env /opt/.env - mv /opt/tianji /opt/tianji_bak - msg_ok "Backed up data" + create_backup /opt/tianji fetch_and_deploy_gh_release "tianji" "msgbyte/tianji" "tarball" + restore_backup msg_info "Updating Tianji" cd /opt/tianji @@ -52,10 +50,8 @@ function update_script() { mkdir -p ./src/server/public cp -r ./geo ./src/server/public $STD pnpm build:server - mv /opt/.env /opt/tianji/src/server/.env cd src/server $STD pnpm db:migrate:apply - rm -rf /opt/tianji_bak rm -rf /opt/tianji/src/client rm -rf /opt/tianji/website rm -rf /opt/tianji/reporter diff --git a/ct/transmute.sh b/ct/transmute.sh index 195bc70c76b..a3b79cbb00d 100644 --- a/ct/transmute.sh +++ b/ct/transmute.sh @@ -31,6 +31,7 @@ function update_script() { fi fetch_and_deploy_gh_release "calibre" "kovidgoyal/calibre" "prebuild" "latest" "/opt/calibre" "calibre-*-x86_64.txz" + restore_backup ln -sf /opt/calibre/ebook-convert /usr/bin/ebook-convert fetch_and_deploy_gh_release "drawio" "jgraph/drawio-desktop" "binary" "latest" "" "drawio-amd64-*.deb" fetch_and_deploy_gh_release "pandoc" "jgm/pandoc" "binary" "latest" "" "pandoc-*-amd64.deb" @@ -40,10 +41,7 @@ function update_script() { systemctl stop transmute msg_ok "Stopped Service" - msg_info "Backing up Data" - cp /opt/transmute/backend/.env /opt/transmute.env.bak - cp -r /opt/transmute/data /opt/transmute_data_bak - msg_ok "Backed up Data" + create_backup /opt/transmute/data CLEAN_INSTALL=1 fetch_and_deploy_gh_release "transmute" "transmute-app/transmute" "tarball" @@ -59,12 +57,6 @@ function update_script() { $STD npm run build msg_ok "Rebuilt Frontend" - msg_info "Restoring Data" - cp /opt/transmute.env.bak /opt/transmute/backend/.env - cp -r /opt/transmute_data_bak/. /opt/transmute/data/ - rm -f /opt/transmute.env.bak - rm -rf /opt/transmute_data_bak - msg_ok "Restored Data" msg_info "Starting Service" systemctl start transmute diff --git a/ct/trilium.sh b/ct/trilium.sh index 750e662f88b..444f6696ccb 100644 --- a/ct/trilium.sh +++ b/ct/trilium.sh @@ -45,19 +45,11 @@ function update_script() { sleep 1 msg_ok "Stopped Service" - msg_info "Backing up Database" - mkdir -p /opt/trilium_backup - cp -r "${DB_PATH}" /opt/trilium_backup/ - rm -rf /opt/trilium - msg_ok "Backed up Database" + create_backup ${DB_PATH} fetch_and_deploy_gh_release "Trilium" "TriliumNext/Trilium" "prebuild" "latest" "/opt/trilium" "TriliumNotes-Server-*linux-x64.tar.xz" + restore_backup - msg_info "Restoring Database" - mkdir -p "$(dirname "${DB_RESTORE_PATH}")" - cp -r /opt/trilium_backup/$(basename "${DB_PATH}") "${DB_RESTORE_PATH}" - rm -rf /opt/trilium_backup - msg_ok "Restored Database" msg_info "Starting Service" systemctl start trilium diff --git a/ct/twenty.sh b/ct/twenty.sh index 19871062f91..5bacc2f1029 100644 --- a/ct/twenty.sh +++ b/ct/twenty.sh @@ -39,10 +39,7 @@ function update_script() { create_backup /opt/twenty/.env \ /opt/twenty/packages/twenty-server/.local-storage CLEAN_INSTALL=1 fetch_and_deploy_gh_release "twenty" "twentyhq/twenty" "tarball" - - msg_info "Restoring Configuration" - cp /opt/twenty.env.bak /opt/twenty/.env - msg_ok "Restored Configuration" + restore_backup msg_info "Building Application" cd /opt/twenty @@ -64,8 +61,6 @@ function update_script() { $STD npx -y typeorm migration:run -d dist/database/typeorm/core/core.datasource msg_ok "Ran Database Migrations" - restore_backup - msg_info "Starting Services" systemctl start twenty-server twenty-worker msg_ok "Started Services" diff --git a/ct/umami.sh b/ct/umami.sh index e612ca36f59..b361421001a 100644 --- a/ct/umami.sh +++ b/ct/umami.sh @@ -34,9 +34,10 @@ function update_script() { systemctl stop umami msg_ok "Stopped Service" - mv /opt/umami/.env /opt/.env.bak + create_backup /opt/umami/.env + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "umami" "umami-software/umami" "tarball" - mv /opt/.env.bak /opt/umami/.env + restore_backup msg_info "Updating Umami" cd /opt/umami diff --git a/ct/wealthfolio.sh b/ct/wealthfolio.sh index ee672c795d0..269009ffed0 100644 --- a/ct/wealthfolio.sh +++ b/ct/wealthfolio.sh @@ -39,19 +39,12 @@ function update_script() { systemctl stop wealthfolio msg_ok "Stopped Service" - msg_info "Backing up Data" - cp -r /opt/wealthfolio_data /opt/wealthfolio_data_backup - cp /opt/wealthfolio/.env /opt/wealthfolio_env_backup - msg_ok "Backed up Data" + create_backup /opt/wealthfolio_data CLEAN_INSTALL=1 fetch_and_deploy_gh_release "wealthfolio" "wealthfolio/wealthfolio" "prebuild" "latest" "/opt/wealthfolio" "wealthfolio-server-*-linux-amd64.tar.gz" + restore_backup install -m 755 /opt/wealthfolio/wealthfolio-server /usr/local/bin/wealthfolio-server - msg_info "Restoring Data" - cp -r /opt/wealthfolio_data_backup/. /opt/wealthfolio_data - cp /opt/wealthfolio_env_backup /opt/wealthfolio/.env - rm -rf /opt/wealthfolio_data_backup /opt/wealthfolio_env_backup - msg_ok "Restored Data" msg_info "Starting Service" systemctl start wealthfolio diff --git a/ct/web-check.sh b/ct/web-check.sh index 32787881012..3c941efe8ea 100644 --- a/ct/web-check.sh +++ b/ct/web-check.sh @@ -34,16 +34,12 @@ function update_script() { systemctl stop web-check msg_ok "Stopped Service" - msg_info "Creating backup" - mv /opt/web-check/.env /opt - msg_ok "Created backup" + create_backup /opt/web-check/.env NODE_VERSION="22" NODE_MODULE="yarn" setup_nodejs CLEAN_INSTALL=1 fetch_and_deploy_gh_release "web-check" "Lissy93/web-check" "tarball" + restore_backup - msg_info "Restoring backup" - mv /opt/.env /opt/web-check - msg_ok "Restored backup" msg_info "Building Web-Check" cd /opt/web-check diff --git a/ct/webtrees.sh b/ct/webtrees.sh index d0fc400090e..6807a86db74 100644 --- a/ct/webtrees.sh +++ b/ct/webtrees.sh @@ -36,17 +36,11 @@ function update_script() { systemctl stop caddy php${PHP_VER}-fpm msg_ok "Stopped Service" - msg_info "Backing up Data" - cp -r /opt/webtrees/data /opt/webtrees_data_backup - msg_ok "Backed up Data" + create_backup /opt/webtrees/data CLEAN_INSTALL=1 fetch_and_deploy_gh_release "webtrees" "fisharebest/webtrees" "prebuild" "latest" "/opt/webtrees" "webtrees-*.zip" + restore_backup - msg_info "Restoring Data" - cp -r /opt/webtrees_data_backup/. /opt/webtrees/data - rm -rf /opt/webtrees_data_backup - chown -R www-data:www-data /opt/webtrees - msg_ok "Restored Data" msg_info "Starting Service" systemctl start caddy php${PHP_VER}-fpm diff --git a/ct/wger.sh b/ct/wger.sh index ec96664b91c..f294c388345 100644 --- a/ct/wger.sh +++ b/ct/wger.sh @@ -35,19 +35,11 @@ function update_script() { systemctl stop redis-server nginx celery celery-beat wger msg_ok "Stopped Service" - msg_info "Backing up Data" - cp -r /opt/wger/media /opt/wger_media_backup - cp /opt/wger/.env /opt/wger_env_backup - msg_ok "Backed up Data" + create_backup /opt/wger/media CLEAN_INSTALL=1 fetch_and_deploy_gh_release "wger" "wger-project/wger" "tarball" + restore_backup - msg_info "Restoring Data" - cp -r /opt/wger_media_backup/. /opt/wger/media - cp /opt/wger_env_backup /opt/wger/.env - rm -rf /opt/wger_media_backup /opt/wger_env_backup - - msg_ok "Restored Data" msg_info "Updating wger" cd /opt/wger diff --git a/ct/wishlist.sh b/ct/wishlist.sh index 7542941eb57..2b4ee899d6d 100644 --- a/ct/wishlist.sh +++ b/ct/wishlist.sh @@ -35,14 +35,10 @@ function update_script() { systemctl stop wishlist msg_ok "Stopped Service" - msg_info "Creating Backup" - mkdir -p /opt/wishlist-backup - cp /opt/wishlist/.env /opt/wishlist-backup/.env - cp -a /opt/wishlist/uploads /opt/wishlist-backup - cp -a /opt/wishlist/data /opt/wishlist-backup - msg_ok "Created Backup" + create_backup /opt/wishlist/uploads /opt/wishlist/data CLEAN_INSTALL=1 fetch_and_deploy_gh_release "wishlist" "cmintey/wishlist" "tarball" + restore_backup LATEST_APP_VERSION=$(get_latest_github_release "cmintey/wishlist") msg_info "Updating Wishlist" @@ -57,12 +53,6 @@ function update_script() { $STD pnpm prune --prod chmod +x /opt/wishlist/entrypoint.sh - msg_info "Restoring Backup" - cp /opt/wishlist-backup/.env /opt/wishlist/.env - cp -a /opt/wishlist-backup/uploads /opt/wishlist - cp -a /opt/wishlist-backup/data /opt/wishlist - rm -rf /opt/wishlist-backup - msg_ok "Restored Backup" msg_ok "Updated Wishlist" msg_info "Starting Service" diff --git a/ct/xyops.sh b/ct/xyops.sh index 140db145026..08c7e0073bc 100644 --- a/ct/xyops.sh +++ b/ct/xyops.sh @@ -35,12 +35,10 @@ function update_script() { systemctl stop xyops msg_ok "Stopped Service" - msg_info "Backing up Data" - cp -r /opt/xyops/data /opt/xyops_data_backup - cp -r /opt/xyops/conf /opt/xyops_conf_backup - msg_ok "Backed up Data" + create_backup /opt/xyops/data /opt/xyops/conf CLEAN_INSTALL=1 fetch_and_deploy_gh_release "xyops" "pixlcore/xyops" "tarball" + restore_backup msg_info "Rebuilding Application" cd /opt/xyops @@ -49,11 +47,6 @@ function update_script() { chmod 644 /opt/xyops/node_modules/useragent-ng/lib/regexps.js msg_ok "Rebuilt Application" - msg_info "Restoring Data" - cp -r /opt/xyops_data_backup/. /opt/xyops/data - cp -r /opt/xyops_conf_backup/. /opt/xyops/conf - rm -rf /opt/xyops_data_backup /opt/xyops_conf_backup - msg_ok "Restored Data" msg_info "Starting Service" systemctl start xyops diff --git a/ct/yourls.sh b/ct/yourls.sh index 680c0a0b3f2..f57d629351b 100644 --- a/ct/yourls.sh +++ b/ct/yourls.sh @@ -35,17 +35,12 @@ function update_script() { systemctl stop nginx msg_ok "Stopped Service" - msg_info "Backing up Configuration" - cp -r /opt/yourls/user /opt/yourls_user.bak - msg_ok "Backed up Configuration" + create_backup /opt/yourls/user CLEAN_INSTALL=1 fetch_and_deploy_gh_release "yourls" "YOURLS/YOURLS" "tarball" + restore_backup chown -R www-data:www-data /opt/yourls - msg_info "Restoring Configuration" - cp -r /opt/yourls_user.bak/. /opt/yourls/user/ - rm -rf /opt/yourls_user.bak - msg_ok "Restored Configuration" msg_info "Starting Service" systemctl start nginx From 1b195cbd1c6ab349ec9cb13a5237a9bd7184a617 Mon Sep 17 00:00:00 2001 From: MickLesk Date: Fri, 19 Jun 2026 23:42:12 +0200 Subject: [PATCH 4/4] 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 72c93f3e656..f489f4a8b47 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 a132e9248fb..bafce28e3f0 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 f21e59a61cd..b26fe8f63c9 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 664efe62af1..e884bc9308d 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 4a7d4ca3d93..292ccb93d6d 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 fefc969268b..9fa6bce7510 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 726bcb65219..bdab1d8e083 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 832f58717cd..5a10b618d8c 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 51a8ffc9e3d..55670539b61 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 abd77c99596..569e7bc586f 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 7acd7a3d6eb..0b267fe6a6d 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 10b15396611..a59723250e7 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 3d619fc0f2b..cbeec7fc3e8 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 b2e3eed289d..9f617393574 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 2216681591f..09e44d0c053 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 664f6832be2..f22d29bea49 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 d43eead41dd..c3ba99faaa5 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 fcdda0438b2..27b75aea425 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 5c60e0a52af..8105366cd8e 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 d42912c1b1d..99e948a9fd7 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 1b55456be1d..33e97d3d80c 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 9d4172ac98b..4657bc528be 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 107573757cb..dde79b0c6f7 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 95e5b63a0d4..84a8bb2f564 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 1f9c3ec69d9..7ad6b02135c 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 cbb8d47902e..a8a218ab959 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 2336b699c8f..de078f76e28 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 cf38d4bd2f6..bc7eed5b8d2 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 431f24231b2..5d3c5f58785 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 ff61931a46e..f7c7445afa6 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 e3646edf4de..2979e954f7d 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 b378c3f017b..46f88b0501d 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 757e447b7fe..a5f95426b01 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 33dada4048c..ee87c831f5b 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 dc49b8af76f..6216ad0a7a2 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 d62ae7812d2..85a271fb1ad 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 4ea49c8f880..b4192044c02 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 474ee1dd330..3e8009f313a 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 aadbba0d6ba..1d6b934b99e 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 33076cd42de..6c2d864670b 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 a461a6d024c..9d36ea2c58c 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 5d8935f80b5..9ac0092bb84 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 a0216d6781b..14b5d34b4c2 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 1d482d8b562..7057d8b8c2b 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 a087e7d27c0..942f3c5c627 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 40fbc066bf5..7f10259c773 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 f28b5846aa5..1e0353c7405 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 0e2731f2a6a..de4ab44ccf7 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 daf3f6dcbce..cced90c81b9 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 06eba233516..ac7542aedc0 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 16b3bd17b72..4613435f68b 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 2520d7d7bf2..41db74cc61d 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"