# bak Asynchronous Pi session backup and restore through S3-compatible object storage. ## Setup Create a private bucket and credentials limited to object read/write access for that bucket. Set: ```text PI_BAK_S3_ENDPOINT=https://.eu.r2.cloudflarestorage.com PI_BAK_S3_ACCESS_KEY_ID=... PI_BAK_S3_SECRET_ACCESS_KEY=... ``` Optional settings: ```text PI_BAK_S3_BUCKET=pi-bak PI_BAK_S3_REGION=auto ``` Initialize each host once: ```text /bak init ``` Host identity lives in platform-local state outside Pi configuration. Catalog autocomplete uses a platform-local stale-while-refresh cache. Bak performs no filesystem or network work during Pi session startup; initialization starts lazily on first command or backup-triggering event. ## Commands ```text /bak /bak init /bak backup /bak restore / [path] /bak restore all [path] /bak refresh /bak status ``` `/bak backup` uploads all locally discoverable sessions. Completed agent runs back up their current session asynchronously. Restore defaults to the current configured session directory and never silently overwrites differing files. ## Tests `mise run //extensions/bak:test` covers the archive logic against an in-memory store. `mise run //extensions/bak:e2e` drives the real bucket named by the `PI_BAK_S3_*` environment. It skips itself when those variables are missing. Every test host uses a throwaway `e2e-*` alias and deletes its objects and catalog entry afterwards.