Skip to content

Telegram: folder backups, several folders per backup, Files schedules, parallel part transfers - #48

Open
ash-iir wants to merge 1 commit into
VD171:mainfrom
ash-iir:tg-files-parallel
Open

ash-iir wants to merge 1 commit into
VD171:mainfrom
ash-iir:tg-files-parallel

Conversation

@ash-iir

@ash-iir ash-iir commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

What

Three requests from Telegram users, done in the backend so any UI can use them:

  1. Files backups on Telegram. A folder backup can now go to a Telegram destination. It is uploaded as <dir>_<ts>.vdbf.tar (the suffix keeps it out of the app lists) and telegram-pull restores it into .paths/<dir>. ERR_TG_KIND now covers /data/adb backups only. The local copy is kept, as before.
  2. Several folders in one Files backup. path-backup takes .paths[] and/or .path (deduplicated, up to 64, each checked as before; paths with spaces work). A single folder writes exactly the old manifest, so an older worker still restores it. Several folders get one archive each (data<i>.<ext>) plus items[] and sources[] in the manifest. Restore runs every safety and checksum check for all folders before it deletes anything.
  3. Files in schedules. schedule-set accepts kind: "files" with paths[] (backup only, ERR_JOB_PATH on bad input). The scheduler runs one path-backup per job and keeps the newest keep backups of that folder set (pinned ones stay). Encrypted runs use the saved default passphrase, like app jobs.

Parallel Telegram transfers. mtproto-store uploads one file on 4 threads but downloads on 1 and sends files one after another. An archive over tg_part_mb (default 256, 64 to 1900) is now split into <name>.partNNNofMMM, and tg_parallel parts (default 3, 1 to 8) move at once, each in its own mtproto-store process with a private copy of the session so no two processes rewrite the session file. Starts are 1 s apart, a failed part is retried once, and if the upload still fails the parts that landed are deleted from the channel. telegram-list folds a complete part set into one entry (message_id becomes "id1,id2,..."), so pull and delete in both UIs work unchanged. Downloads fetch parts in parallel and stream them in order into tar. Archives under the part size upload exactly as before. This also lifts the 2000 MiB per-file limit for large app backups.

Settings: tg_parallel and tg_part_mb are plain config keys. The New interface (#47) has the UI for folder lists, Files schedules, Telegram folder restores and the parallel setting.

How it was tested

Not tested on a device or against real Telegram. In a Linux sandbox, the real worker.sh and helper.sh ran in a user-namespace chroot with a fake /data and a fake mtproto-store:

  • a 3-folder backup (one 150 MB folder, one path with a space) uploaded as 3 parallel parts, telegram-list showed one entry, the pull was byte-identical and the restore brought back all 3 folders;
  • a part that failed once was retried; a part that always failed gave ERR_TRANSFER, the landed parts were deleted and staging and session copies were cleaned up;
  • bad paths, message_ids and names were refused with the expected codes; the old single-file app pull still works;
  • three scheduler runs pruned the folder set to keep=2.

sh -n and shellcheck -s sh -S error are clean.

Known limits

  • Archives under the part size still download on one thread (a limit of the binary).
  • An older module sees a split backup as .partNNNofMMM items; cat name.part* > name joins them.
  • The progress bar holds at the transfer phase while parts move.
  • Scheduled Files jobs prune local copies only, like app jobs.
  • New strings are in English; other languages fall back to it.

…el Telegram parts

- Files backups can go to a Telegram destination as <dir>_<ts>.vdbf.tar
  (kept out of the app lists); telegram-pull restores them into .paths/.
  ERR_TG_KIND now covers /data/adb backups only.
- path-backup takes .paths[] and/or .path (deduplicated, up to 64). A single
  folder writes the old manifest unchanged; several folders get one archive
  each plus items[] and sources[]. Restore checks every folder before it
  deletes anything.
- schedule-set accepts kind "files" with paths[] (backup only); the
  scheduler runs one path-backup per job and keeps the newest keep copies.
- An archive over tg_part_mb (default 256, 64 to 1900) is split into
  .partNNNofMMM and tg_parallel parts (default 3, 1 to 8) move at once, each
  mtproto-store process on its own session copy. A failed part is retried
  once; on failure the parts that landed are deleted. telegram-list folds a
  complete part set into one entry, so pull and delete work unchanged.
  Downloads fetch parts in parallel and stream them in order into tar.

Signed-off-by: ash-iir <254348575+ash-iir@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant