feat: async iCloud prefetch + keep-local for Mackup folder

lib/icloud.sh (new):
  ssr::icloud::prefetch <dir>    — spawn background open -g requests for
    all .icloud stubs; returns immediately so other work can run in parallel.
  ssr::icloud::wait <dir> [sec]  — poll until stubs are gone or timeout
    (default 180s). Logs progress every 5s.
  ssr::icloud::keep_local <dir>  — after sync, removes
    com.apple.icloud.evictable xattr from every real file + updates
    access-time (LRU delay), preventing iCloud from re-creating stubs
    before the next run. Best-effort (no public pin API on macOS CLI).

bin/ssr-sync:
  - prefetch Mackup folder immediately after cloud is available (before
    brew update/upgrade) so downloads proceed in the background.
  - ssr::icloud::wait called just before mackup backup.
  - ssr::icloud::keep_local called after sync completes.
  - SSR_ICLOUD_WAIT_TIMEOUT (default 180) and SSR_ICLOUD_KEEP_LOCAL
    (default true) config toggles added.

bin/ssr-restore:
  - prefetch Mackup folder right after cloud is validated, before the
    brew bundle install step, maximising download time available.

config/ssr.conf.example:
  Added SSR_ICLOUD_WAIT_TIMEOUT and SSR_ICLOUD_KEEP_LOCAL keys.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-12 09:46:12 +02:00
parent 634487b9d8
commit 698cbe145a
4 changed files with 146 additions and 0 deletions
+12
View File
@@ -24,6 +24,18 @@ SSR_BREW_CLEANUP=true
# ---------------------------------------------------------------------------
# Unmanaged-app scan during sync
# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------
# iCloud prefetch & keep-local
# ---------------------------------------------------------------------------
# Trigger async iCloud download at sync/restore start so files are available
# before Mackup runs. Wait up to this many seconds before proceeding.
# SSR_ICLOUD_WAIT_TIMEOUT=180
# After sync, mark Mackup folder files as keep-local to prevent iCloud from
# re-evicting them before the next run (LRU touch + xattr, best-effort).
SSR_ICLOUD_KEEP_LOCAL=true
# ---------------------------------------------------------------------------
# Lists .app bundles installed manually (not via brew cask, not via MAS).
# Writes <backup_dir>/unmanaged-apps.txt for restore-time reference.