# bak
Keep Pi sessions available across machines through S3-compatible object storage.
Backups let you resume or retrieve session history after moving to another host without copying session files by hand.
## Set up
Use a private bucket and credentials limited to that bucket's object read and write access.
Provide access credentials through environment variables, never settings files.
Set the endpoint there too, or configure its non-secret location in Pi settings.
```text
PI_BAK_S3_ENDPOINT=https://.eu.r2.cloudflarestorage.com
PI_BAK_S3_ACCESS_KEY_ID=...
PI_BAK_S3_SECRET_ACCESS_KEY=...
```
Start Pi, then assign this machine an alias:
```text
/bak init laptop
```
`bak` remains disabled until its endpoint and credentials are present.
Install through [Installation](../../README.md#install).
## Use it in Pi
Automatic backup is on by default after setup.
Pi uploads the current session after completed work and keeps retryable uploads pending when a backup fails.
Use `/bak backup` to upload every locally discoverable session now.
On another configured machine, find a session with `/bak search `, then restore a listed result with `/bak restore /`.
Add a destination path to restore elsewhere: `/bak restore / /path/to/sessions`.
`/bak restore all [path]` restores every session in a remote catalog.
Restore reports conflicting files instead of silently replacing them.
Use `/bak status` to check setup, pending uploads, and catalog state.
Set `bak.autoBackup` to `false` in trusted project or user Pi settings when you want manual backups only.
## Reference
### Commands
| Command | Purpose |
| --- | --- |
| `/bak` | Back up and restore Pi sessions |
### Setting names
| Setting | Environment |
| --- | --- |
| `bak.autoBackup` | `PI_BAK_AUTO_BACKUP` |
| `bak.s3.bucket` | `PI_BAK_S3_BUCKET` |
| `bak.s3.endpoint` | `PI_BAK_S3_ENDPOINT` |
| `bak.s3.region` | `PI_BAK_S3_REGION` |