# Сохранность: перезапуск API, PostgreSQL и Redis с сохранением volumes
# дата: 2026-10-08T15:55Z, commit: 6473fd0
# стенд: Apple M3 Pro, 11 CPU, 18 GB RAM, macOS 26.1, Docker 29.3.0, Compose 5.1.0

# до перезапуска
postgres  StartedAt=2026-10-08T15:55:04.230004924Z
redis     StartedAt=2026-10-08T15:55:04.230356549Z
api       StartedAt=2026-10-08T15:55:10.436053969Z

$ cat scripts/restart.sh
#!/bin/sh
# Перезапускает API и оба хранилища. Volumes не трогает: данные и сессии должны остаться.
set -eu
cd "$(dirname "$0")/.."
docker compose --env-file .env restart postgres redis api

$ make test-persistence ACTION_SCRIPT=scripts/restart.sh
python3 tests/resilience.py --mode persistence --action-script "scripts/restart.sh" --base-url "http://localhost:8080" 
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.

# после перезапуска: у всех трёх контейнеров новое время старта
postgres  StartedAt=2026-10-08T15:55:15.070657346Z
redis     StartedAt=2026-10-08T15:55:15.160837596Z
api       StartedAt=2026-10-08T15:55:15.392988013Z

$ docker volume ls --filter name=mtusi-messenger-lab2
DRIVER    VOLUME NAME
local     mtusi-messenger-lab2_pgdata
local     mtusi-messenger-lab2_redisdata

# повторный запуск миграций
$ docker compose --env-file .env run --rm migrate
 Container mtusi-messenger-lab2-postgres-1 Running 
 Container mtusi-messenger-lab2-postgres-1 Waiting 
 Container mtusi-messenger-lab2-postgres-1 Healthy 
 Container mtusi-messenger-lab2-migrate-run-c47ffc8919e4 Creating 
 Container mtusi-messenger-lab2-migrate-run-c47ffc8919e4 Created 
уже применена: 0001_init.sql

$ psql: SELECT * FROM schema_migrations
    version    |          applied_at           
---------------+-------------------------------
 0001_init.sql | 2026-10-08 15:55:10.184216+00
(1 row)

