Code Server AI backs up workspace files, code-server/OpenCode configuration, and the Gitea PostgreSQL database to RustFS S3-compatible storage.
The code-server workspace is mounted at /workspace from the fixed Docker named volume codeserver-ai-workspace. Backups archive this path so workspace contents survive code-server container rebuilds and Dokploy updates.
Set these on the code-server container:
RUSTFS_ACCESS_KEY=your-rustfs-access-key
RUSTFS_SECRET_KEY=your-rustfs-secret-key
RUSTFS_ENDPOINT=http://rustfs:9000
RUSTFS_BUCKET=code-server-backups
POSTGRES_HOST=pgbouncer
POSTGRES_PORT=6432
POSTGRES_USER=gitea
POSTGRES_DB=gitea
POSTGRES_PASSWORD=your-postgres-passwordThe backup script creates RUSTFS_BUCKET if it does not exist.
Run the backup from the code-server container:
docker exec code-server /scripts/backup.shExpected backup names:
workspace-YYYYMMDD-HHMMSS.tar.gz
config-YYYYMMDD-HHMMSS.tar.gz
gitea-YYYYMMDD-HHMMSS.sql.gz
Add this to the host crontab:
0 2 * * * docker exec code-server /scripts/backup.sh >> /tmp/backup.log 2>&1List backups:
docker exec code-server sh -c 'aws s3 ls s3://code-server-backups/ --endpoint-url http://rustfs:9000'Restore workspace or config:
docker exec code-server /scripts/restore.sh workspace-20240101-120000.tar.gz
docker exec code-server /scripts/restore.sh config-20240101-120000.tar.gzRestore the Gitea database:
docker exec code-server /scripts/restore.sh gitea-20240101-120000.sql.gz
docker restart giteaThe restore script creates a pre-restore snapshot in /tmp/pre-restore-snapshot/ before applying changes.
- Local temporary backups: 7 days
- Remote RustFS backups: 7 days
Old backups are cleaned automatically by /scripts/backup.sh.
Includes:
- User workspace files
- Claude memory data
- Git repositories
- Installed extensions
Includes:
- Code Server configuration
- OpenCode provider configuration
- User dotfiles under
/home/coder/.config
Includes:
- User accounts
- Repository metadata
- Issues and pull requests
- Wiki data
docker exec code-server sh -c 'tail -n 100 /tmp/backup.log'
docker logs code-serverCommon causes:
- Missing
RUSTFS_ACCESS_KEYorRUSTFS_SECRET_KEY - Missing
POSTGRES_PASSWORD - RustFS is not reachable from
code-server - The RustFS bucket cannot be listed or created
docker exec code-server sh -c 'tail -n 100 /tmp/restore.log'
docker logs code-server
docker logs giteaCommon causes:
- Backup filename does not match the expected format
- Missing
POSTGRES_PASSWORDfor Gitea database restore - Gitea database connection settings are wrong
- The downloaded archive is empty or corrupt
- Store credentials in Dokploy/Docker secrets or environment variables.
- Never commit
.env, API keys, RustFS credentials, or generated passwords. - Use TLS termination at the reverse proxy.
- Keep code-server upstream protocol as
HTTPbehind the proxy. - Rotate service credentials regularly.