Skip to content
Open
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: 1 addition & 1 deletion companion/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ am start-foreground-service \
# 2) first-run consent (VISIBLE Activity, the one unavoidable UI step)
am start \
-n ru.vd171.vdbackup/.ConsentActivity \
-e result /data/adb/vdbackup/drive/consent.json
-e result /data/data/ru.vd171.vdbackup/files/consent.json
# user signs in; result JSON: ok=true code=ERR_NONE, or ok=false code=ERR_CONSENT_DENIED
```

Expand Down
13 changes: 11 additions & 2 deletions companion/app/src/main/kotlin/ru/vd171/vdbackup/ConsentActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import com.google.android.gms.auth.api.signin.GoogleSignInClient
import com.google.android.gms.auth.api.signin.GoogleSignInOptions
import com.google.android.gms.common.api.ApiException
import com.google.android.gms.common.api.Scope
import java.io.File

class ConsentActivity : Activity() {

Expand Down Expand Up @@ -71,13 +72,21 @@ class ConsentActivity : Activity() {
}

private fun finishWith(ok: Boolean, code: String, msg: String? = null) {
intent.getStringExtra(EXTRA_RESULT)?.let { path ->
CommandResult.write(path, ok, "consent", code, null, msg ?: if (ok) "consent granted" else "consent denied")
resultFile()?.let { f ->
CommandResult.write(f.path, ok, "consent", code, null, msg ?: if (ok) "consent granted" else "consent denied")
}
setResult(if (ok) RESULT_OK else RESULT_CANCELED)
finish()
}

// The Activity is exported (root starts it with `am start`), so the result path
// comes from any caller: accept only a consent.* file directly in our files dir.
private fun resultFile(): File? {
val path = intent.getStringExtra(EXTRA_RESULT) ?: return null
val f = runCatching { File(path).canonicalFile }.getOrNull() ?: return null
return f.takeIf { it.parentFile == filesDir.canonicalFile && it.name.startsWith("consent.") }
}

companion object {
private const val RC_SIGN_IN = 0x7D1
const val EXTRA_RESULT = "result"
Expand Down
18 changes: 16 additions & 2 deletions module/scripts/worker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,14 @@ item_paths() {
# every backend namespaces its data under <path>/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
Expand Down Expand Up @@ -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
Expand All @@ -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() { # <label> <src> <basepct>
[ -e "$2" ] || return 0
case "$DTYPE" in
Expand Down Expand Up @@ -1475,6 +1484,7 @@ do_restore_mirror() {
resolve_dest
transport_guard mirror || return
[ "$DTYPE" = local ] || net_guard || return
mirror_local_dest || return
prog 5 fetching "$PKG"; audit "restore-mirror start $PKG"; notify restore_start "$PKG"
if [ "$DTYPE" = local ]; then SRC="$(remote_pfx)/$PKG"
else SRC="$STATE/staging/mrestore.$OPID"; rm -rf "$SRC"; mkdir -p "$SRC"
Expand Down Expand Up @@ -2230,6 +2240,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
Expand Down Expand Up @@ -2346,6 +2359,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"
Expand Down
1 change: 1 addition & 0 deletions module/webroot/lang/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
"msg_err_dest_id": "اسم الوجهة مفقود أو غير صالح.",
"msg_err_dest_none": "لم تعد هذه الوجهة موجودة.",
"msg_err_dest_type": "نوع الوجهة هذا غير مدعوم.",
"msg_err_tg_kind": "وجهات تيليجرام تحفظ نسخ التطبيقات الاحتياطية فقط. اختر وجهة أخرى لنسخ المجلدات و /data/adb.",
"msg_err_dest_unreach": "تعذّر الوصول إلى الوجهة.",
"msg_err_drive": "تعذّر الوصول إلى Google Drive. يرجى منح الإذن والمحاولة مرة أخرى.",
"msg_err_drive_consent": "لم يُمنح الإذن لـ Google Drive بعد. يرجى منح الإذن والمحاولة مرة أخرى.",
Expand Down
1 change: 1 addition & 0 deletions module/webroot/lang/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
"msg_err_dest_id": "Název cíle chybí nebo je neplatný.",
"msg_err_dest_none": "Tento cíl již neexistuje.",
"msg_err_dest_type": "Tento typ cíle není podporován.",
"msg_err_tg_kind": "Cíle Telegram uchovávají jen zálohy aplikací. Pro zálohy složek a /data/adb vyberte jiný cíl.",
"msg_err_dest_unreach": "Cíl nebylo možné kontaktovat.",
"msg_err_drive": "Google Drive nebylo možné kontaktovat. Udělte prosím oprávnění a zkuste to znovu.",
"msg_err_drive_consent": "Google Drive zatím není autorizován. Udělte prosím oprávnění a zkuste to znovu.",
Expand Down
1 change: 1 addition & 0 deletions module/webroot/lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
"msg_err_dest_id": "Der Zielname fehlt oder ist ungültig.",
"msg_err_dest_none": "Dieses Ziel existiert nicht mehr.",
"msg_err_dest_type": "Dieser Zieltyp wird nicht unterstützt.",
"msg_err_tg_kind": "Telegram-Ziele speichern nur App-Backups. Wähle für Ordner- und /data/adb-Backups ein anderes Ziel.",
"msg_err_dest_unreach": "Das Ziel konnte nicht erreicht werden.",
"msg_err_drive": "Google Drive konnte nicht erreicht werden. Bitte autorisiere den Zugriff und versuche es erneut.",
"msg_err_drive_consent": "Google Drive ist noch nicht autorisiert. Bitte autorisiere den Zugriff und versuche es erneut.",
Expand Down
1 change: 1 addition & 0 deletions module/webroot/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
1 change: 1 addition & 0 deletions module/webroot/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
1 change: 1 addition & 0 deletions module/webroot/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
"msg_err_dest_id": "El nombre del destino falta o no es válido.",
"msg_err_dest_none": "Ese destino ya no existe.",
"msg_err_dest_type": "Ese tipo de destino no es compatible.",
"msg_err_tg_kind": "Los destinos de Telegram solo guardan copias de apps. Elige otro destino para copias de carpetas y de /data/adb.",
"msg_err_dest_unreach": "No se pudo acceder al destino.",
"msg_err_drive": "No se pudo acceder a Google Drive. Autoriza el acceso e inténtalo de nuevo.",
"msg_err_drive_consent": "Google Drive aún no está autorizado. Autoriza el acceso e inténtalo de nuevo.",
Expand Down
1 change: 1 addition & 0 deletions module/webroot/lang/fa.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
"msg_err_dest_id": "نام مقصد موجود نیست یا نامعتبر است.",
"msg_err_dest_none": "این مقصد دیگر وجود ندارد.",
"msg_err_dest_type": "این نوع مقصد پشتیبانی نمی‌شود.",
"msg_err_tg_kind": "مقصدهای تلگرام فقط پشتیبان برنامه‌ها را نگه می‌دارند. برای پشتیبان پوشه‌ها و /data/adb مقصد دیگری انتخاب کنید.",
"msg_err_dest_unreach": "دسترسی به مقصد ممکن نشد.",
"msg_err_drive": "دسترسی به Google Drive ممکن نشد. لطفاً دسترسی را مجاز کنید و دوباره تلاش کنید.",
"msg_err_drive_consent": "هنوز به Google Drive اجازه داده نشده است. لطفاً دسترسی را مجاز کنید و دوباره تلاش کنید.",
Expand Down
1 change: 1 addition & 0 deletions module/webroot/lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
"msg_err_dest_id": "Le nom de la destination est manquant ou invalide.",
"msg_err_dest_none": "Cette destination n'existe plus.",
"msg_err_dest_type": "Ce type de destination n'est pas pris en charge.",
"msg_err_tg_kind": "Les destinations Telegram ne conservent que les sauvegardes d'apps. Choisissez une autre destination pour les sauvegardes de dossiers et de /data/adb.",
"msg_err_dest_unreach": "La destination n'a pas pu être atteinte.",
"msg_err_drive": "Google Drive n'a pas pu être atteint. Veuillez autoriser l'accès et réessayer.",
"msg_err_drive_consent": "Google Drive n'est pas encore autorisé. Veuillez autoriser l'accès et réessayer.",
Expand Down
1 change: 1 addition & 0 deletions module/webroot/lang/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
"msg_err_dest_id": "गंतव्य का नाम गायब है या अमान्य है.",
"msg_err_dest_none": "वह गंतव्य अब मौजूद नहीं है.",
"msg_err_dest_type": "उस प्रकार का गंतव्य समर्थित नहीं है.",
"msg_err_tg_kind": "Telegram गंतव्य केवल ऐप बैकअप रखते हैं। फ़ोल्डर और /data/adb बैकअप के लिए कोई दूसरा गंतव्य चुनें।",
"msg_err_dest_unreach": "गंतव्य तक नहीं पहुंचा जा सका.",
"msg_err_drive": "Google Drive तक नहीं पहुंचा जा सका. कृपया पहुंच अधिकृत करें और फिर से प्रयास करें.",
"msg_err_drive_consent": "Google Drive अभी अधिकृत नहीं है. कृपया पहुंच अधिकृत करें और फिर से प्रयास करें.",
Expand Down
1 change: 1 addition & 0 deletions module/webroot/lang/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
"msg_err_dest_id": "Nama tujuan tidak ada atau tidak valid.",
"msg_err_dest_none": "Tujuan itu tidak ada lagi.",
"msg_err_dest_type": "Jenis tujuan itu tidak didukung.",
"msg_err_tg_kind": "Tujuan Telegram hanya menyimpan cadangan aplikasi. Pilih tujuan lain untuk cadangan folder dan /data/adb.",
"msg_err_dest_unreach": "Tujuan tidak dapat dijangkau.",
"msg_err_drive": "Google Drive tidak dapat dijangkau. Silakan izinkan akses dan coba lagi.",
"msg_err_drive_consent": "Google Drive belum diizinkan. Silakan izinkan akses dan coba lagi.",
Expand Down
1 change: 1 addition & 0 deletions module/webroot/lang/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
"msg_err_dest_id": "Il nome della destinazione è mancante o non valido.",
"msg_err_dest_none": "Quella destinazione non esiste più.",
"msg_err_dest_type": "Quel tipo di destinazione non è supportato.",
"msg_err_tg_kind": "Le destinazioni Telegram contengono solo backup di app. Scegli un'altra destinazione per i backup di cartelle e di /data/adb.",
"msg_err_dest_unreach": "Impossibile raggiungere la destinazione.",
"msg_err_drive": "Impossibile raggiungere Google Drive. Autorizza l'accesso e riprova.",
"msg_err_drive_consent": "Google Drive non è ancora autorizzato. Autorizza l'accesso e riprova.",
Expand Down
1 change: 1 addition & 0 deletions module/webroot/lang/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
"msg_err_dest_id": "保存先の名前がないか無効です。",
"msg_err_dest_none": "その保存先はもう存在しません。",
"msg_err_dest_type": "その保存先の種類はサポートされていません。",
"msg_err_tg_kind": "Telegram の保存先はアプリのバックアップ専用です。フォルダと /data/adb のバックアップには別の保存先を選んでください。",
"msg_err_dest_unreach": "保存先に到達できませんでした。",
"msg_err_drive": "Google Drive に到達できませんでした。アクセスを許可してもう一度お試しください。",
"msg_err_drive_consent": "Google Drive はまだ承認されていません。アクセスを許可してもう一度お試しください。",
Expand Down
1 change: 1 addition & 0 deletions module/webroot/lang/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
"msg_err_dest_id": "대상 이름이 없거나 올바르지 않습니다.",
"msg_err_dest_none": "해당 대상이 더 이상 존재하지 않습니다.",
"msg_err_dest_type": "해당 대상 유형은 지원되지 않습니다.",
"msg_err_tg_kind": "Telegram 대상에는 앱 백업만 저장됩니다. 폴더 및 /data/adb 백업에는 다른 대상을 선택하세요.",
"msg_err_dest_unreach": "대상에 연결할 수 없습니다.",
"msg_err_drive": "Google Drive에 연결할 수 없습니다. 접근을 승인한 후 다시 시도해 주세요.",
"msg_err_drive_consent": "Google Drive가 아직 승인되지 않았습니다. 접근을 승인한 후 다시 시도해 주세요.",
Expand Down
1 change: 1 addition & 0 deletions module/webroot/lang/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
"msg_err_dest_id": "De naam van de bestemming ontbreekt of is ongeldig.",
"msg_err_dest_none": "Die bestemming bestaat niet meer.",
"msg_err_dest_type": "Dat type bestemming wordt niet ondersteund.",
"msg_err_tg_kind": "Telegram-bestemmingen bewaren alleen app-back-ups. Kies een andere bestemming voor map- en /data/adb-back-ups.",
"msg_err_dest_unreach": "De bestemming kon niet worden bereikt.",
"msg_err_drive": "Google Drive kon niet worden bereikt. Autoriseer de toegang en probeer het opnieuw.",
"msg_err_drive_consent": "Google Drive is nog niet geautoriseerd. Autoriseer de toegang en probeer het opnieuw.",
Expand Down
1 change: 1 addition & 0 deletions module/webroot/lang/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
"msg_err_dest_id": "Nazwa celu jest pusta lub nieprawidłowa.",
"msg_err_dest_none": "Ten cel już nie istnieje.",
"msg_err_dest_type": "Ten typ celu nie jest obsługiwany.",
"msg_err_tg_kind": "Miejsca docelowe Telegram przechowują tylko kopie aplikacji. Wybierz inne miejsce dla kopii folderów i /data/adb.",
"msg_err_dest_unreach": "Nie można było połączyć się z celem.",
"msg_err_drive": "Nie można było połączyć się z Google Drive. Autoryzuj dostęp i spróbuj ponownie.",
"msg_err_drive_consent": "Google Drive nie jest jeszcze autoryzowany. Autoryzuj dostęp i spróbuj ponownie.",
Expand Down
1 change: 1 addition & 0 deletions module/webroot/lang/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
"msg_err_dest_id": "O nome do destino está ausente ou é inválido.",
"msg_err_dest_none": "Esse destino não existe mais.",
"msg_err_dest_type": "Esse tipo de destino não é suportado.",
"msg_err_tg_kind": "Os destinos do Telegram guardam apenas backups de apps. Escolha outro destino para backups de pastas e de /data/adb.",
"msg_err_dest_unreach": "Não foi possível acessar o destino.",
"msg_err_drive": "Não foi possível acessar o Google Drive. Autorize o acesso e tente novamente.",
"msg_err_drive_consent": "O Google Drive ainda não está autorizado. Autorize o acesso e tente novamente.",
Expand Down
1 change: 1 addition & 0 deletions module/webroot/lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
"msg_err_dest_id": "Имя назначения отсутствует или недопустимо.",
"msg_err_dest_none": "Это назначение больше не существует.",
"msg_err_dest_type": "Этот тип назначения не поддерживается.",
"msg_err_tg_kind": "Назначения Telegram хранят только резервные копии приложений. Для копий папок и /data/adb выберите другое назначение.",
"msg_err_dest_unreach": "Не удалось связаться с назначением.",
"msg_err_drive": "Не удалось связаться с Google Drive. Разрешите доступ и попробуйте ещё раз.",
"msg_err_drive_consent": "Google Drive ещё не авторизован. Разрешите доступ и попробуйте ещё раз.",
Expand Down
1 change: 1 addition & 0 deletions module/webroot/lang/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
"msg_err_dest_id": "Målets namn saknas eller är ogiltigt.",
"msg_err_dest_none": "Det målet finns inte längre.",
"msg_err_dest_type": "Den måltypen stöds inte.",
"msg_err_tg_kind": "Telegram-mål sparar bara appsäkerhetskopior. Välj ett annat mål för mapp- och /data/adb-säkerhetskopior.",
"msg_err_dest_unreach": "Målet kunde inte nås.",
"msg_err_drive": "Google Drive kunde inte nås. Godkänn åtkomsten och försök igen.",
"msg_err_drive_consent": "Google Drive är inte godkänt ännu. Godkänn åtkomsten och försök igen.",
Expand Down
1 change: 1 addition & 0 deletions module/webroot/lang/th.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
"msg_err_dest_id": "ชื่อปลายทางหายไปหรือไม่ถูกต้อง",
"msg_err_dest_none": "ปลายทางนั้นไม่มีอยู่แล้ว",
"msg_err_dest_type": "ไม่รองรับประเภทปลายทางนั้น",
"msg_err_tg_kind": "ปลายทาง Telegram เก็บได้เฉพาะข้อมูลสำรองของแอป เลือกปลายทางอื่นสำหรับข้อมูลสำรองโฟลเดอร์และ /data/adb",
"msg_err_dest_unreach": "ไม่สามารถเข้าถึงปลายทางได้",
"msg_err_drive": "ไม่สามารถเข้าถึง Google Drive ได้ โปรดอนุญาตการเข้าถึงแล้วลองอีกครั้ง",
"msg_err_drive_consent": "ยังไม่ได้อนุญาต Google Drive โปรดอนุญาตการเข้าถึงแล้วลองอีกครั้ง",
Expand Down
1 change: 1 addition & 0 deletions module/webroot/lang/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
"msg_err_dest_id": "Hedef adı eksik veya geçersiz.",
"msg_err_dest_none": "Bu hedef artık mevcut değil.",
"msg_err_dest_type": "Bu hedef türü desteklenmiyor.",
"msg_err_tg_kind": "Telegram hedefleri yalnızca uygulama yedeklerini tutar. Klasör ve /data/adb yedekleri için başka bir hedef seçin.",
"msg_err_dest_unreach": "Hedefe ulaşılamadı.",
"msg_err_drive": "Google Drive'a ulaşılamadı. Lütfen erişime izin verip tekrar deneyin.",
"msg_err_drive_consent": "Google Drive henüz yetkilendirilmedi. Lütfen erişime izin verip tekrar deneyin.",
Expand Down
Loading