diff --git a/lib/mackup.sh b/lib/mackup.sh index 70a15b4..68dd667 100644 --- a/lib/mackup.sh +++ b/lib/mackup.sh @@ -44,13 +44,21 @@ ssr::mackup::_materialize_icloud() { *Mobile\ Documents*) ;; # only worth doing for iCloud *) return 0 ;; esac - # `brctl download` is the documented way to request file materialization. - # Available on macOS 10.12+; silently skip if missing on older systems. - if command -v brctl >/dev/null 2>&1; then - brctl download "$mackup_root" >/dev/null 2>&1 || true - fi - # Belt-and-braces: prune any stub files that survived the download - # request (sometimes left over from interrupted prior runs). + # `brctl download` was removed in macOS Sonoma (remaining brctl subcommands: + # diagnose/log/dump/status/accounts/quota/monitor). The current way to + # trigger per-file iCloud download from the CLI is `open -g `, + # which asks the iCloud daemon to fetch the file in the background. + find "$mackup_root" -name '*.icloud' -type f 2>/dev/null | while IFS= read -r stub; do + local dir base real + dir="$(dirname "$stub")" + base="$(basename "$stub")" + real="${base#.}" # strip leading dot + real="${real%.icloud}" # strip .icloud suffix + open -g "$dir/$real" 2>/dev/null || true + done + # Brief pause so the iCloud daemon can start fetching before mackup reads. + sleep 1 + # Belt-and-braces: prune any stubs that couldn't be resolved. find "$mackup_root" -name '*.icloud' -type f -delete 2>/dev/null || true } @@ -93,5 +101,6 @@ ssr::mackup::backup() { ssr::mackup::restore() { ssr::log "mackup restore" - mackup restore + # -f: answer "yes" to all prompts (consistent with backup behaviour). + mackup -f restore }