fix: persist memory across Docker restarts #2
@@ -0,0 +1,39 @@
|
|||||||
|
# Docker persistence runbook
|
||||||
|
|
||||||
|
The bot stores all runtime state under `DATA_DIR`:
|
||||||
|
|
||||||
|
- `data/global_memory.json` — global facts and preferences;
|
||||||
|
- `data/sessions/` — topic conversation histories;
|
||||||
|
- `data/calendar_token.json` — OAuth refresh token when used.
|
||||||
|
|
||||||
|
`docker-compose.yml` explicitly sets `DATA_DIR=/app/data` and mounts `./data:/app/data`. Do not use `docker compose down -v` as a substitute for a backup: named volumes are not used by this compose file, but the host `data/` directory must be kept.
|
||||||
|
|
||||||
|
## Safe upgrade
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir -p data
|
||||||
|
cp -a data "data.backup.$(date +%Y%m%d-%H%M%S)"
|
||||||
|
git pull
|
||||||
|
docker compose up -d --build
|
||||||
|
```
|
||||||
|
|
||||||
|
If the old container contained the only copy of the state, copy it before removing that container:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker cp homeagent:/app/data/. ./data/
|
||||||
|
```
|
||||||
|
|
||||||
|
Check that the files are visible from the new container:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose exec homeagent sh -lc 'printf "DATA_DIR=%s\\n" "$DATA_DIR"; ls -la /app/data; test -f /app/data/global_memory.json && head -c 1 /app/data/global_memory.json'
|
||||||
|
```
|
||||||
|
|
||||||
|
A previous `No space left on device` error can still prevent persistence. Check the host before deployment:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
df -h .
|
||||||
|
docker system df
|
||||||
|
```
|
||||||
|
|
||||||
|
Do not delete Docker data or the host `data/` directory until a backup has been verified.
|
||||||
Reference in new issue
Block a user