Skip to content

worker: fail a special backup that is incomplete or empty - #23

Draft
ash-iir wants to merge 1 commit into
mainfrom
fix-special-backup-check
Draft

ash-iir wants to merge 1 commit into
mainfrom
fix-special-backup-check

Conversation

@ash-iir

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

Copy link
Copy Markdown
Owner

Backend #13. do_special_backup could finish ok with items:[] or with truncated archives: no crypto_available check (unlike the other encrypting verbs), each tar | comp | enc_age failure only continued inside a subshell, tar's own exit was masked by the pipe, and the only success test was [ -s manifest.json ].

  • With a passphrase, crypto_available is checked first (ERR_CRYPTO_UNAVAIL, existing message).
  • Each archive uses the same checks as archive_dir: the .trc sentinel for a fatal tar exit (>1; exit 1 for files changing under tar is still fine), and a read-back with tar -t (through dec_age when encrypted). A failure removes that archive and marks the backup failed.
  • A selected category that produced no item (no provider path on this device, or every archive failed) fails the backup. system_settings counts only when it was opted in.
  • On failure the incomplete .special/<ts> directory is removed and the op ends with ERR_BACKUP.

The per-path loop runs in a pipe subshell, so the failure is passed out through a .sfail file in the backup dir.

Testing

  • sh -n, mksh -n, busybox sh -n; shellcheck -s sh: one more SC2016 note (jq $c in single quotes, like the rest of the file).
  • The real do_special_backup with stubbed special_paths/media_own, real tar, zstd, age 1.2.1 and script, under mksh R59, busybox 1.37 ash and dash: plain 2-category backup ok with 2 items; encrypted backup ok and its archive opens with the passphrase; missing crypto gives ERR_CRYPTO_UNAVAIL; a category with no path, a fatal tar exit and a truncated archive each give ERR_BACKUP and leave no backup dir.
  • Not tested on a rooted device.

A special backup reported success even when nothing usable was written:
there was no crypto check, archive failures were dropped silently, the
tar exit status was masked, and the only test was a non-empty manifest.

- Check crypto_available up front when a passphrase is set.
- Use the same .trc sentinel and read-back check as archive_dir for
  each archive; a failure removes that archive and fails the backup.
- Fail when a selected category produced no item.
- A failed special backup removes its incomplete directory.

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