Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/FILE-STRUCTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>.json
├── README.md + README.<code>.md # English + the 21 standard languages
Expand Down
42 changes: 39 additions & 3 deletions module/scripts/helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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 (<pfx>/<pkg>/meta.json, one live copy per app, no <ts_vc>)
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,<pkg>), 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/<pkg>/<ts_vc>/ Drive folders). Same entry shape as rclone-list plus a Drive `folder` id
Expand Down Expand Up @@ -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 <<EOF
Expand Down Expand Up @@ -1794,6 +1819,17 @@ EOF
done
printf ']}\n' ;;

bootstrap)
# first-paint data in one exec (the WebUI bridge runs one exec at a time): the same JSON the
# separate verbs print, keyed by verb. Every verb stays callable on its own.
printf '{"ok":true'
for _v in config-get ping list-users list-ops dests-list; do
_o="$(sh "$0" "$_v" '')"; printf ',"%s":%s' "$_v" "${_o:-null}"
done
_o="$(sh "$0" overview "$(printf '{"user":0}' | base64)")"; printf ',"overview":%s' "${_o:-null}"
_o="$(sh "$0" log-read "$(printf '{"limit":4}' | base64)")"; printf ',"log-read":%s' "${_o:-null}"
printf '}\n' ;;

*)
err ERR_UNKNOWN_VERB "unknown verb: $verb" ;;

Expand Down
38 changes: 36 additions & 2 deletions module/scripts/worker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,45 @@ progx() {
_pxn="$6"; case "$_pxn" in ''|*[!0-9]*) _pxn=0 ;; esac
_pxo="$7"; case "$_pxo" in ''|*[!0-9]*) _pxo=0 ;; esac
printf '{"opid":"%s","percent":%s,"phase":"%s","item":"%s","done":false,"rate":"%s","eta":"%s","n":%s,"of":%s,"cur":"%s"}\n' \
"$OPID" "$1" "$(jstr "$2")" "$(jstr "$3")" "$(jstr "$4")" "$(jstr "$5")" "$_pxn" "$_pxo" "$(jstr "$8")" > "$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 <tag> 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 <tag> <text>
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: "<time> <pid>".
prog_notify() {
[ -n "${_NPROG+x}" ] || _NPROG="$(cfg .notify_progress)"
[ "$_NPROG" = true ] || return 0
_npf="$STATE/staging/np.$OPID"; _npt="$(date +%s)"
read -r _npl _npp 2>/dev/null < "$_npf"
[ $(( _npt - ${_npl:-0} )) -ge 5 ] || return 0
[ -n "${_npp:-}" ] && kill -0 "$_npp" 2>/dev/null && return 0
printf '%s\n' "$_npt" > "$_npf" 2>/dev/null || return 0
npost "vdbackup_$OPID" "$1%${2:+ - $2}" &
printf '%s %s\n' "$_npt" "$!" > "$_npf"
}
prog_notify_wait() { # let a pending progress post land before a final text replaces it
read -r _npl _npp 2>/dev/null < "$STATE/staging/np.$OPID" || return 0
_npw=0
while [ -n "${_npp:-}" ] && kill -0 "$_npp" 2>/dev/null && [ "$_npw" -lt 3 ]; do sleep 1; _npw=$(( _npw + 1 )); done
}
prog() { # prog <percent> <phase> <item> (back-compat: no rich extras)
progx "$1" "$2" "$3" "" "" 0 0 ""; }
finish() { # finish <ok> <code>; inside a batch it records the per-app result instead of
# writing the terminal state, so one app's end does not end the whole batch op.
if [ "${IN_BATCH:-0}" = 1 ]; then LAST_OK="$1"; LAST_CODE="$2"; return 0; fi
# a progress notification with no done notice after it would stay at its last percent
if [ -f "$STATE/staging/np.$OPID" ]; then
prog_notify_wait; rm -f "$STATE/staging/np.$OPID"
if [ "$1" = true ]; then _npm="100%"; else _npm="$2"; fi
npost "vdbackup_$OPID" "$_npm"
fi
printf '{"opid":"%s","percent":100,"phase":"finished","done":true,"ok":%s,"code":"%s"}\n' \
"$OPID" "$1" "$2" > "$PROG"; }
audit() { printf '{"ts":"%s","op":"%s","opid":"%s","detail":"%s"}\n' \
Expand Down Expand Up @@ -368,7 +401,8 @@ notify() {
_nl="$(cfg .language)"; case "$_nl" in ""|null|auto) _nl=en ;; esac
_nn="$2"; case "$_nn" in *.*) _lbl="$(notify_label "$_nn")"; [ -n "$_lbl" ] && _nn="$_lbl" ;; esac
if command -v vdb_notify_msg >/dev/null 2>&1; then _nm="$(vdb_notify_msg "$_nl" "$1" "$_nn")"; else _nm="$_nn"; fi
fw cmd notification post -t "VDBackup" "vdbackup_$OPID" "$_nm" >/dev/null 2>&1 && return 0
prog_notify_wait; case "$1" in *_done) rm -f "$STATE/staging/np.$OPID" ;; esac
npost "vdbackup_$OPID" "$_nm" && return 0
[ -f "$MODDIR/etc/vdbackup_helper.dex" ] && LD_LIBRARY_PATH= app_process -Djava.class.path="$MODDIR/etc/vdbackup_helper.dex" \
/system/bin ru.vd171.vdbackup.Helper notify "VDBackup" "$_nm" >/dev/null 2>&1; }

Expand Down
13 changes: 13 additions & 0 deletions module/webroot/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<link rel="icon" href="assets/logo-icon.svg">
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="vdlu.css">
<script src="ui-switch.js"></script>
</head>
<body>
<header class="topbar">
Expand Down Expand Up @@ -273,6 +274,14 @@ <h2 class="section-head" id="remote-head"><span class="sh-ic"><svg viewBox="0 0

<section id="settings" class="panel">
<div class="card">
<div class="field">
<label for="ui-mode-sel" data-i18n="settings_interface">Interface</label>
<select id="ui-mode-sel">
<option value="classic" data-i18n="opt_ui_classic">Classic</option>
<option value="next" data-i18n="opt_ui_next">New</option>
</select>
<div class="muted" data-i18n="settings_interface_hint">Switch between the classic interface and the new one. Both have every feature, and you can switch back at any time.</div>
</div>
<div class="field">
<label data-i18n="settings_theme">Theme</label>
<select id="set-theme">
Expand Down Expand Up @@ -375,6 +384,10 @@ <h2 class="section-head" id="remote-head"><span class="sh-ic"><svg viewBox="0 0
<input type="checkbox" class="switch" id="set-thermal"><span data-i18n="settings_thermal">Pause to cool down when the device gets hot</span>
</div>
<div class="muted" data-i18n="settings_thermal_hint">During a long backup, VDBackup waits a moment between apps if the device is running hot, so a big batch cannot overheat it. On by default.</div>
<div class="field check">
<input type="checkbox" class="switch" id="set-notify-progress"><span data-i18n="settings_notify_progress">Show progress in a notification</span>
</div>
<div class="muted" data-i18n="settings_notify_progress_hint">While a backup or restore runs, a notification shows its percent and current app, updated every few seconds. Off by default.</div>
<div class="field check">
<input type="checkbox" class="switch" id="set-space-preflight"><span data-i18n="settings_space_preflight">Check free space before a batch backup</span>
</div>
Expand Down
63 changes: 62 additions & 1 deletion module/webroot/lang/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"item_obb": "OBB",
"item_external": "البيانات الخارجية",
"item_media": "الوسائط",
"item_profiles": "ملفات تعريف ART",
"restore": "استعادة",
"confirm_restore": "استعادة ${name}؟ سيؤدي هذا إلى الكتابة فوق بيانات التطبيق الحالية.",
"op_running": "جارٍ العمل...",
Expand Down Expand Up @@ -584,6 +585,7 @@
"confirm_clear_logs": "مسح سجل النشاط بالكامل؟ لا يمكن التراجع عن هذا.",
"ui_delete_selected": "حذف",
"confirm_delete_n": "حذف ${n} نسخة احتياطية محددة؟ لا يمكن التراجع عن هذا.",
"confirm_delete_n_size": "حذف ${n} نسخة احتياطية محددة (${size})؟ لا يمكن التراجع عن هذا.",
"settings_relaunch": "إعادة فتح التطبيقات بعد النسخ الاحتياطي",
"settings_relaunch_hint": "بعد نسخة احتياطية واحدة، يُعاد فتح التطبيق الذي كان قيد التشغيل عند إيقافه مؤقتًا لأخذ اللقطة. مُعطّل افتراضيًا؛ لا تتأثر النسخ الاحتياطية بالدفعات والمجدولة.",
"ui_dest_gdrive_hint": "يتطلب تطبيق Google Drive المرافق عميل OAuth خاصًا به من Google Cloud يُضبط وقت البناء. للحصول على Drive بدون أي إعداد، أضف بدلاً من ذلك وجهة \"Google Drive (rclone)\" أدناه.",
Expand All @@ -592,5 +594,64 @@
"settings_reset_config": "إعادة تعيين الإعدادات (الوجهات، الجداول الزمنية، الإعدادات المسبقة، بيانات الاعتماد)",
"settings_reset_backups": "حذف جميع النسخ الاحتياطية المحلية",
"settings_reset_btn": "إعادة تعيين المحدد",
"confirm_reset_data": "سيؤدي هذا إلى مسح البيانات المحددة نهائيا ولا يمكن التراجع عنه. هل تريد المتابعة؟"
"confirm_reset_data": "سيؤدي هذا إلى مسح البيانات المحددة نهائيا ولا يمكن التراجع عنه. هل تريد المتابعة؟",
"settings_interface": "الواجهة",
"settings_interface_hint": "بدّل بين الواجهة الكلاسيكية والواجهة الجديدة. تحتوي الواجهتان على كل الميزات، ويمكنك الرجوع في أي وقت.",
"opt_ui_classic": "الكلاسيكية",
"opt_ui_next": "الجديدة",
"nx_home": "الرئيسية",
"nx_more": "المزيد",
"nx_storage": "مساحة النسخ الاحتياطي",
"nx_quick": "إجراءات سريعة",
"nx_qa_backup": "نسخ التطبيقات احتياطيا",
"nx_qa_restore": "استعادة",
"nx_seg_system": "بيانات النظام",
"nx_seg_files": "الملفات",
"nx_seg_import": "استيراد",
"nx_recent": "النشاط الأخير",
"nx_see_all": "عرض الكل",
"nx_more_dests": "محلي، خوادم سحابية، restic، Drive، Telegram",
"nx_more_settings": "المظهر، الإعدادات الافتراضية، التشفير، الأتمتة",
"nx_more_log": "كل نسخ احتياطي واستعادة وحذف",
"nx_more_updates": "التحقق من وجود إصدار جديد",
"nx_more_about": "الإصدار والروابط والشكر",
"nx_switch_classic": "التبديل إلى الواجهة الكلاسيكية",
"nx_boot_err": "حدث خطأ أثناء تحميل هذه الواجهة.",
"nx_grp_appearance": "المظهر",
"nx_grp_defaults": "إعدادات النسخ الافتراضية",
"nx_grp_security": "التشفير",
"nx_grp_automation": "الأتمتة",
"nx_grp_apps": "قواعد لكل تطبيق",
"nx_grp_restore": "خيارات الاستعادة",
"nx_grp_data": "بيانات الإعدادات وإعادة التعيين",
"nx_tab_backup": "نسخ احتياطي",
"nx_ov_apps": "تطبيقات منسوخة",
"nx_src_local": "على الجهاز",
"nx_src_all": "الكل",
"nx_f_full": "كامل",
"nx_f_snapshot": "لقطة",
"nx_f_mirror": "مرآة",
"nx_f_pinned": "مثبتة",
"nx_sort_new": "الأحدث أولا",
"nx_sort_old": "الأقدم أولا",
"nx_sort_size": "الأكبر أولا",
"nx_retry": "إعادة المحاولة",
"nx_src_signin": "تسجيل الدخول",
"nx_src_login": "سجل الدخول إلى تيليجرام لرؤية النسخ المخزنة هناك.",
"nx_bk_nomatch": "لا توجد نسخ تطابق هذه المرشحات.",
"nx_bk_no_uninstalled": "لا توجد نسخ لتطبيقات غير مثبّتة.",
"nx_rs_download": "تنزيل إلى هذا الجهاز",
"nx_rs_where": "مخزنة في",
"settings_notify_progress": "عرض التقدم في إشعار",
"settings_notify_progress_hint": "أثناء النسخ الاحتياطي أو الاستعادة يعرض إشعار النسبة والتطبيق الحالي، ويتحدث كل بضع ثوان. معطل افتراضيا.",
"nx_pb_add": "إضافة",
"nx_pb_remove": "إزالة",
"nx_pb_multi_hint": "أضف مجلدا واحدا أو أكثر: تُحفظ معا في نسخة احتياطية واحدة.",
"nx_n_folders": "${n} مجلدات",
"nx_job_what": "المحتوى",
"nx_job_kind_apps": "التطبيقات",
"nx_job_folders": "المجلدات",
"nx_job_need_folder": "أضف مجلدا واحدا على الأقل.",
"settings_tg_parallel": "عمليات نقل Telegram المتوازية",
"settings_tg_parallel_msg": "تنتقل النسخة الاحتياطية الكبيرة من Telegram وإليه على أجزاء. يُنقل هذا العدد من الأجزاء في وقت واحد: العدد الأكبر أسرع مع اتصال جيد، والقيمة 1 ترسل جزءا واحدا في كل مرة."
}
Loading