From 29b7fcf08fb7d8b8548eb4fedfdfb0a41f1ea15b Mon Sep 17 00:00:00 2001 From: ash-iir <254348575+ash-iir@users.noreply.github.com> Date: Thu, 19 Nov 2026 12:10:02 +0000 Subject: [PATCH 1/4] worker: refuse folder and /data/adb backups to a Telegram destination Telegram stores one archive per app backup and telegram-pull restores only those. A folder or /data/adb backup to Telegram failed at upload time, after the local copy was written, and could not have been pulled back. Refuse it right after the destination is resolved with ERR_TG_KIND, and add the matching English message. Signed-off-by: ash-iir <254348575+ash-iir@users.noreply.github.com> (cherry picked from commit 98798e382168a57c1455402d59ce5abed3199d1a) --- module/scripts/worker.sh | 4 ++++ module/webroot/lang/en.js | 1 + module/webroot/lang/en.json | 1 + 3 files changed, 6 insertions(+) diff --git a/module/scripts/worker.sh b/module/scripts/worker.sh index cc63ee9..c8c6f1f 100644 --- a/module/scripts/worker.sh +++ b/module/scripts/worker.sh @@ -2230,6 +2230,9 @@ do_path_backup() { if [ "$ENCDATA" = true ] && ! crypto_available; then finish false ERR_CRYPTO_UNAVAIL; return; fi use_data_age() { [ "$ENCDATA" = true ] && [ -n "$PW" ]; } resolve_dest + # Telegram stores one archive per app backup and telegram-pull restores only those, so a + # folder backup there could never come back: refuse it up front, before any work. + [ "$DTYPE" = telegram ] && { finish false ERR_TG_KIND; return; } transport_guard full || return prog 2 preparing "path"; audit "path-backup start $SRCP"; notify backup_start "path" SAFE="$(printf '%s' "$SRCP" | sed -e 's#^/##' -e 's#[^A-Za-z0-9._-]#_#g')"; [ -n "$SAFE" ] || SAFE=path @@ -2346,6 +2349,7 @@ do_adb_backup() { use_data_age() { [ "$ENCDATA" = true ] && [ -n "$PW" ]; } U=0 # /data/adb is system-wide, not per-user resolve_dest + [ "$DTYPE" = telegram ] && { finish false ERR_TG_KIND; return; } # app backups only (see do_path_backup) transport_guard full || return prog 2 preparing "adb"; audit "adb-backup start"; notify backup_start "adb" BACKUPS="$(backups_dir "$U")"; BK="$BACKUPS/.adb"; TS="$(date -u +%Y%m%dT%H%M%SZ)"; DEST="$BK/$TS" diff --git a/module/webroot/lang/en.js b/module/webroot/lang/en.js index 55a0012..b33c7c6 100644 --- a/module/webroot/lang/en.js +++ b/module/webroot/lang/en.js @@ -230,6 +230,7 @@ window.__I18N_EN = { "msg_err_dest_id": "The destination name is missing or invalid.", "msg_err_dest_none": "That destination no longer exists.", "msg_err_dest_type": "That destination type is not supported.", + "msg_err_tg_kind": "Telegram destinations hold app backups only. Pick another destination for folder and /data/adb backups.", "msg_err_dest_unreach": "The destination could not be reached.", "msg_err_drive": "Google Drive could not be reached. Please authorize access and try again.", "msg_err_drive_consent": "Google Drive is not authorized yet. Please authorize access and try again.", diff --git a/module/webroot/lang/en.json b/module/webroot/lang/en.json index c90feb0..5934c30 100644 --- a/module/webroot/lang/en.json +++ b/module/webroot/lang/en.json @@ -205,6 +205,7 @@ "msg_err_dest_id": "The destination name is missing or invalid.", "msg_err_dest_none": "That destination no longer exists.", "msg_err_dest_type": "That destination type is not supported.", + "msg_err_tg_kind": "Telegram destinations hold app backups only. Pick another destination for folder and /data/adb backups.", "msg_err_dest_unreach": "The destination could not be reached.", "msg_err_drive": "Google Drive could not be reached. Please authorize access and try again.", "msg_err_drive_consent": "Google Drive is not authorized yet. Please authorize access and try again.", From c5ed15b687def3eddbff5434f69b4d93b2134cbe Mon Sep 17 00:00:00 2001 From: ash-iir <254348575+ash-iir@users.noreply.github.com> Date: Thu, 19 Nov 2026 12:17:42 +0000 Subject: [PATCH 2/4] worker: give a local Mirror an absolute, allowed destination The default local destination has no path, so Mirror mode wrote to and restored from "vdbackup" relative to the worker's cwd. Default it to .mirror in the user's backups dir, and refuse a local Mirror path that fails safe_local_dest, as a full backup's local copy already does. A failed APK sync now also fails the mirror instead of being ignored. Signed-off-by: ash-iir <254348575+ash-iir@users.noreply.github.com> (cherry picked from commit 306997823b23de2fc8d578292efe490031181fb8) --- module/scripts/worker.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/module/scripts/worker.sh b/module/scripts/worker.sh index c8c6f1f..23957eb 100644 --- a/module/scripts/worker.sh +++ b/module/scripts/worker.sh @@ -832,6 +832,14 @@ item_paths() { # every backend namespaces its data under /vdbackup so our files never # collide with the user's other files at the chosen destination path. remote_pfx() { printf '%s' "${DPATH:+$DPATH/}vdbackup"; } +# A local Mirror needs an absolute, allowed root: the default local destination has no path, +# which would make remote_pfx relative to the worker's cwd. Default it to a hidden dir in the +# user's backups dir, then apply the same storage allowlist as a full backup's local copy. +mirror_local_dest() { + [ "$DTYPE" = local ] || return 0 + [ -n "$DPATH" ] || DPATH="$(backups_dir "$U")/.mirror" + safe_local_dest "$DPATH" || { audit "refused unsafe local dest $DPATH $PKG"; finish false ERR_DEST_UNSAFE; return 1; } +} # Live rclone transfer: run rclone with periodic one-line stats and feed progx so the # WebUI shows percent / speed / ETA. A sentinel file carries rclone's real exit code @@ -967,8 +975,10 @@ do_snapshot() { do_mirror() { [ -n "$DREMOTE" ] || [ "$DTYPE" = local ] || { finish false ERR_NO_DEST; return; } [ "$DTYPE" = local ] || net_guard || return + mirror_local_dest || return prog 5 freezing "$PKG"; notify backup_start "$PKG" freeze "$PKG" + _bfail=0 # APK: always compressed, never raw (even in a mirror) if echo " $ITEMS " | grep -q ' apk '; then prog 18 mirror apk @@ -978,10 +988,9 @@ do_mirror() { case "$DTYPE" in local) mkdir -p "$(remote_pfx)/$PKG/apk" && exec_ns "$RSYNC" -a --delete "$apkdir/" "$(remote_pfx)/$PKG/apk/" >/dev/null 2>&1 ;; rclone) rclone_live "mirror apk" 18 sync "$apkdir" "$DREMOTE:$(remote_pfx)/$PKG/apk" ;; - esac + esac || { _bfail=1; audit "mirror sync failed $PKG (apk)"; } rm -rf "$apkdir" fi - _bfail=0 sync_one() { #