diff --git a/docs/FILE-STRUCTURE.md b/docs/FILE-STRUCTURE.md index 5ce05f9e..aeae36b3 100644 --- a/docs/FILE-STRUCTURE.md +++ b/docs/FILE-STRUCTURE.md @@ -28,6 +28,8 @@ VD-Backup/ │ ├── i18n.js # translation engine (I18N.t / apply / init / set) │ ├── styles.css # dark theme │ ├── config.json # WebUI manifest (title, icon, strict CSP, no network) +│ ├── ui-switch.js # Interface switch: Classic (index.html, default) or New (next/) +│ ├── next/ # opt-in New interface: index.html + css/ + js/, shares scripts.js, i18n and lang/ │ ├── assets/ # logo-icon.svg, logo-wordmark.svg │ └── lang/ # en.js (fallback) + en.json + 20 more .json ├── README.md + README..md # English + the 21 standard languages diff --git a/module/scripts/helper.sh b/module/scripts/helper.sh index f70613c6..5b6c3785 100644 --- a/module/scripts/helper.sh +++ b/module/scripts/helper.sh @@ -141,7 +141,7 @@ backup_listing() { else "$JQ" -c '{package:.package.name, label:(.package.label // .package.name), icon:(.package.icon // ""), versionName:.package.versionName, versionCode:.package.versionCode, - created_at:.created_at, mode:.mode, types:[.items[].type], encrypted:false, locked:false}' "$_bl_m" 2>/dev/null + created_at:.created_at, mode:.mode, types:[.items[].type], size:([.items[].size // 0] | add // 0), encrypted:false, locked:false}' "$_bl_m" 2>/dev/null fi } @@ -676,9 +676,34 @@ case "$verb" in case "$_tsvc" in */*) continue ;; esac [ "$_first" = 1 ] || printf ','; _first=0 printf '{"dest":"%s","rref":"%s","package":"%s","tsvc":"%s"}' "$(jstr "$id")" "$(jstr "$_rref")" "$(jstr "$_pkg")" "$(jstr "$_tsvc")" - done; } + done + # mirrors:true also lists Mirror copies (//meta.json, one live copy per app, no ) + if [ "$(printf '%s' "$ARGS_B64" | base64 -d 2>/dev/null | "$JQ" -r '.mirrors // false' 2>/dev/null)" = true ]; then + "$_rc" --config "$SECRETS/rclone.conf" lsf -R --max-depth 2 --files-only --format tp --include meta.json "$rem:$pfx/" 2>/dev/null \ + | while IFS= read -r _l; do + _p="${_l#*;}"; _pkg="${_p%/meta.json}" + case "$_pkg" in ''|*/*) continue ;; esac + [ "$_first" = 1 ] || printf ','; _first=0 + printf '{"dest":"%s","rref":"%s","package":"%s","tsvc":"","mode":"mirror","mtime":"%s"}' "$(jstr "$id")" "$(jstr "$_pkg")" "$(jstr "$_pkg")" "$(jstr "${_l%%;*}")" + done + fi; } printf ']}\n' ;; + restic-list) + # list the Snapshot-mode snapshots of a restic destination (tagged vdbackup,), newest first. + # Restore takes one by id through restore {mode:"snapshot",dest,package,snapshot}. + JQ="$(command -v "$BIN/jq" 2>/dev/null || echo jq)" + id="$(printf '%s' "$ARGS_B64" | base64 -d 2>/dev/null | "$JQ" -r '.dest // empty' 2>/dev/null)" + f="$STATE/dests/$id.json" + { [ -n "$id" ] && [ -f "$f" ] && [ "$("$JQ" -r '.type // empty' "$f")" = restic ]; } || { err ERR_DEST_NONE "no such restic destination"; exit 0; } + repo="$("$JQ" -r '.repo // empty' "$f")" + _rs="$(command -v "$BIN/restic" 2>/dev/null || command -v "$STATE/bin/restic" 2>/dev/null || echo restic)" + _o="$(RCLONE_CONFIG="$SECRETS/rclone.conf" RESTIC_PASSWORD_FILE="$SECRETS/creds/$id.pass" "$_rs" -r "$repo" snapshots --json --tag vdbackup 2>/dev/null)" + [ -n "$_o" ] || { err ERR_RESTIC "could not list the restic snapshots"; exit 0; } + printf '%s' "$_o" | "$JQ" -c --arg d "$id" '{ok:true, dest:$d, backups:([.[]? | {dest:$d, id:.id, short_id:.short_id, time:.time, + package:(((.tags // []) | map(select(. != "vdbackup")))[0] // ""), size:(.summary.total_bytes_processed // 0)}] | sort_by(.time) | reverse)}' 2>/dev/null \ + || err ERR_RESTIC "could not list the restic snapshots" ;; + gdrive-list) # list Full backups stored on a Google Drive destination (via the companion, which walks the # vdbackup/// Drive folders). Same entry shape as rclone-list plus a Drive `folder` id @@ -1029,7 +1054,7 @@ case "$verb" in printf '%s' "$(backup_listing "$ref")" | "$JQ" -c --arg ref "$ref" --argjson hasapk "$_hasapk" --argjson nt "$_nt" --argjson pin "$_pin" \ '{ref:$ref, package:.package, label:.label, versionName:.versionName, versionCode:.versionCode, created_at:.created_at, mode:.mode, - note:$nt.note, tags:$nt.tags, pinned:$pin, encrypted:.encrypted, locked:.locked, + note:$nt.note, tags:$nt.tags, pinned:$pin, encrypted:.encrypted, locked:.locked, size:(.size // 0), items:((if $hasapk then ["apk"] else [] end) + .types)}' 2>/dev/null done done < "$PROG"; } + "$OPID" "$1" "$(jstr "$2")" "$(jstr "$3")" "$(jstr "$4")" "$(jstr "$5")" "$_pxn" "$_pxo" "$(jstr "$8")" > "$PROG" + prog_notify "$1" "${8:-$3}"; } +# Post (or replace) the notification as the shell user, which every ROM shows; a post +# from uid 0 goes out as package "root" and some ROMs drop it without an error. Root is the +# fallback when su cannot switch users. npost +npost() { + fw NP_TAG="$1" NP_TXT="$2" su -p 2000 -c 'cmd notification post -t VDBackup "$NP_TAG" "$NP_TXT"' >/dev/null 2>&1 \ + || fw cmd notification post -t "VDBackup" "$1" "$2" >/dev/null 2>&1 +} +# Optional progress notification (config notify_progress, default off): text-only "42% - item", +# posted in the background on the op's own tag (the start/done notices reuse it), at most every +# 5 s and never while the previous post is still running. State file: "