Updating
Status: Complete
How to update your Chatalot instance to the latest version.
Before You Update
- Read the changelog for breaking changes between your current version and the target version.
- Back up your instance before updating. See Backup and Restore.
- Check your current version:
curl -s http://localhost:8080/api/health | python3 -c "import sys,json; print(json.load(sys.stdin)['version'])"
Docker Update
Pull and Rebuild
The build will only recompile changed source files thanks to Docker's cache mounts. Migrations run automatically on startup.
Verify the Update
The version field in the health response should reflect the new version.
Using the Deploy Script
If you are deploying to a remote server, the scripts/deploy.sh script handles the full workflow:
# Pull latest on the server and rebuild
DEPLOY_HOST=user@your-server \
DEPLOY_DIR=/srv/chatalot \
DEPLOY_GIT_URL=ssh://git@github.com/you/chatalot.git \
./scripts/deploy.sh --pull-only
The deploy script:
- SSHs to the server
- Pulls the latest code from git
- Generates secrets if they do not exist
- Runs
docker compose up -d --build - Waits for the health check to pass (up to 60 seconds)
- Reports success or failure
Manual Deployment Update
If you are running without Docker:
cd /path/to/chatalot
# Pull latest code
git pull
# Rebuild the server
export SQLX_OFFLINE=true
cargo build --release
# Rebuild WASM crypto module (if crates/chatalot-crypto* changed)
./scripts/build-wasm.sh
# Rebuild the web client
cd clients/web && npm ci && npm run build && cd ../..
# Copy updated files to the install location
sudo cp target/release/chatalot-server /opt/chatalot/bin/
sudo cp -r clients/web/build/* /opt/chatalot/static/
sudo cp -r migrations/* /opt/chatalot/migrations/
sudo chown -R chatalot:chatalot /opt/chatalot
# Restart the service (migrations run automatically)
sudo systemctl restart chatalot
Database Migrations
Migrations are applied automatically every time the server starts. The server calls sqlx::migrate!() which:
- Checks which migrations have already been applied
- Runs any pending migrations in order
- Records each migration in the
_sqlx_migrationstable
You do not need to run migrations manually. If a migration fails, the server will log the error and exit. Fix the issue and restart.
Zero-Downtime Considerations
Chatalot does not currently support zero-downtime updates. During the update process:
- Users with active WebSocket connections will be disconnected
- The web client will attempt to reconnect automatically
- Pending requests will fail with connection errors
To minimize disruption:
- Schedule updates during low-activity periods
- The restart itself is fast (seconds) -- most of the update time is the Docker build
- Build the image first, then swap:
# Build without restarting
docker compose build
# Quick swap (seconds of downtime)
docker compose up -d
Rollback
If an update causes issues, you can roll back to a previous version:
Git Rollback
# Find the previous commit
git log --oneline -10
# Roll back to a specific commit
git checkout <commit-hash>
# Rebuild and restart
docker compose up -d --build
Database Rollback
Warning: Rolling back database migrations is not automatically supported. If a new migration altered the schema, rolling back the code without reverting the migration may cause errors.
If you need to undo a migration:
-
Check what the migration did:
-
Manually reverse it:
-
Roll back the code and restart:
Full Restore from Backup
If the rollback is complex, it may be easier to restore from a backup:
# Stop everything
docker compose down
# Roll back the code
git checkout <previous-commit>
# Restore database
docker compose up -d postgres
sleep 5
docker exec chatalot-db psql -U chatalot -c "DROP DATABASE chatalot;"
docker exec chatalot-db psql -U chatalot -c "CREATE DATABASE chatalot OWNER chatalot;"
docker exec -i chatalot-db pg_restore -U chatalot -d chatalot < backup.dump
# Restore files
docker run --rm \
-v chatalot_file_storage:/data \
-v $(pwd):/backup \
alpine sh -c "rm -rf /data/* && tar xzf /backup/files_backup.tar.gz -C /data"
# Start everything
docker compose up -d --build
Checking for Updates
Next Step
For monitoring your running instance, see Monitoring.