Skip to content

feat: prune backups of uninstalled apps during incremental backup#126

Open
mvanhorn wants to merge 1 commit into
YAWAsau:masterfrom
mvanhorn:feat/124-prune-uninstalled-app-backups
Open

feat: prune backups of uninstalled apps during incremental backup#126
mvanhorn wants to merge 1 commit into
YAWAsau:masterfrom
mvanhorn:feat/124-prune-uninstalled-app-backups

Conversation

@mvanhorn

Copy link
Copy Markdown

Summary

Adds an opt-in prune_uninstalled setting so a re-run of backup also reflects app removals, not just additions. When enabled, after a backup completes the script compares the backed-up app folders against the live installed-package list and offers to delete the backups of apps that have been uninstalled since the last run (folder + its appList.txt entry).

  • New config flag prune_uninstalled (default 0, off) in both update_backup_settings_conf (tools/tools.sh) and backup_settings.conf.
  • New prune_uninstalled_backups() reuses the existing detection idiom from get_name (PackageName-vs-$Apk_info diff) and the existing per-name folder + appList.txt deletion idiom.
  • Wired into the real backup path: it runs at the end of a full backup and before the incremental "no app updated" early-exit, so uninstall-only changes are still pruned on a no-op incremental run.

Why this matters

Per #124, re-running a backup today adds newly installed apps but never drops the stored copy of an app that was uninstalled since the last run, so a later restore re-installs apps the user removed. This implements the reporter's requested behavior (compare previous vs current app set, drop backups of apps no longer installed).

Safety:

  • Opt-in and default-off — existing users see no behavior change.
  • Two-step confirmation before any deletion (matches the script's existing destructive-delete convention); declining deletes nothing.
  • Parse-failure protection — a folder whose package name cannot be resolved is skipped, never deleted.
  • Local-only — only the local backup is pruned. Streaming-upload mode is skipped (no local files), and when a remote target is configured the run prints a notice that remote directories are not touched.

Testing

  • bash -n tools/tools.sh passes.
  • Manual reasoning against the scenarios in the issue:
    • device has B C D E F, backup dir has A B C D E F, prune_uninstalled=1 → A's folder and its appList.txt line are removed after confirmation.
    • prune_uninstalled=0 (default) → uninstalled app's backup retained as today, no prompt.
    • no orphans → "nothing to prune", backup untouched.
    • confirmation declined → no folders deleted.
    • unresolvable package name → folder skipped (protected).

Fixes #124

@YAWAsau

YAWAsau commented Jun 23, 2026

Copy link
Copy Markdown
Owner

The script is currently undergoing extensive refactoring and feature additions. I will merge this commit once it is stable.

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.

[Feature]第二次备份的应用删除

2 participants