Backups & updates
Daily S3 backups, restore, local copies, update the image (including to the 0.6 server), reset a player's password, the website hooks (account links, hosted tournaments), and what the server keeps.
What to back up
All state is one SQLite database (WAL mode), rugen.db, in the
rugen-data volume: accounts (with their password hashes and login keys), ratings, seasons, rooms and stored ranked
replays. Character packages live next to it in packages/; they are caches
that players upload again on demand (size the volume for
RUGEN_PKG_MAX_TOTAL).
Off-site backups (S3)
Set RUGEN_BACKUP_S3 (see Configuration)
and the server backs itself up to the bucket once a day at 03:00 UTC.
- Create a bucket (R2’s free tier holds 10 GB with no egress fees; a database backup is usually a few MB).
- Create an API token / access key limited to that bucket with object read, write, list and delete (R2: Object Read & Write on the bucket).
- Put the one-line URL in the server’s environment (Dokploy: Environment
tab) and redeploy. The start-up log says
backups: daily at 03:00 UTC to … keep 7 days.
Schedule
- One automatic backup a day at 03:00 UTC. It survives restarts and redeploys: on start the server lists the bucket, and if the newest backup is older than 24 hours one runs 5 minutes after boot; otherwise it waits for the next 03:00.
- Never more than one automatic backup a day: a slot is skipped when a backup (automatic or manual) succeeded in the 20 hours before it.
- A failed automatic backup is retried once, an hour later.
Retention
After every successful backup, backups older than
RUGEN_BACKUP_RETENTION_DAYS (default 7) are deleted. The newest
complete backup is always kept, however old. Only objects named
rugen-backup-* under <prefix>/backups/ (and backups/packages/ with
RUGEN_BACKUP_INCLUDE=packages) are touched: other files in the bucket
are left alone.
Bucket layout
The server keeps its own tree under the prefix of RUGEN_BACKUP_S3 (the
path after the bucket; when there is none, the tree starts at the bucket
root), with year / month folders:
<prefix>/
├── backups/ everything backups write, nothing else
│ ├── db/2026/10/
│ │ ├── rugen-backup-20261013T030000Z-0.6.0.db.zst the database, zstd-compressed
│ │ └── rugen-backup-20261013T030000Z-0.6.0.json manifest: version, schema, sizes, sha256
│ ├── keys/2026/10/
│ │ └── rugen-backup-20261013T030000Z-0.6.0.signing.key only with signing-key
│ └── packages/
│ └── <fingerprint>.rgc|.rgs|.rgpk only with packages
├── chars/ reserved: content uploads (later)
└── stages/ reserved: content uploads (later)
Backups never write, list for deletion or delete anything outside
<prefix>/backups/, so the same bucket can hold other content.
Old flat backups
Version 0.6.0 wrote its backups flat, directly under the prefix
(<prefix>/rugen-backup-….db.zst and .json). They keep working:
GET /v1/admin/backups lists them with "legacy": true, and
--restore latest falls back to them while no backup of the new layout
exists. After the first successful backup in the new layout they are
deleted automatically: exactly the objects <prefix>/rugen-backup-*.db.zst
and <prefix>/rugen-backup-*.json, nothing else. An old flat
.signing.key or <prefix>/packages/ folder is left in place; delete it
by hand if you had one.
What a backup contains
- The database: a consistent snapshot taken while the server runs
(
VACUUM INTOthrough a second connection, so players are never blocked), compressed with zstd and streamed up. Memory use stays at one copy buffer whatever the size; there is no extra process. - Packages (opt-in,
RUGEN_BACKUP_INCLUDE=packages): they can be gigabytes and are re-uploaded by players anyway, so they are left out by default. When included they are uploaded incrementally: names are content fingerprints, and a package already in the bucket with the same size is never sent again. Packages gone from the server are deleted from the bucket once older than the retention. - Signing key (opt-in,
RUGEN_BACKUP_INCLUDE=signing-key): the generated<data>/signing.keyof a community server.
Admin API
With RUGEN_ADMIN_TOKEN set (send it as Authorization: Bearer <token>,
?token= or {"token": "…"}):
| Call | Answer |
|---|---|
POST /v1/admin/backup | 202 {"job": 3, "state": "running"}; 409 while one runs; 429 with retry_after (one manual backup per 10 minutes). |
GET /v1/admin/backups | {"backups": [{"key", "name", "time", "size", "complete", "legacy"}]}, newest first (legacy: an old flat 0.6.0 backup). |
GET /v1/admin/backup/status | The /health backup object plus job, last_backup, include, daily_at. |
curl -X POST -H "Authorization: Bearer $RUGEN_ADMIN_TOKEN" https://play.example.com/v1/admin/backup
Admin calls are limited to RUGEN_RATE_ADMIN (30) per IP per minute.
From a shell, rugen-server --backup-now does the same as the POST.
Health
GET /health carries a backup object. It never contains the endpoint,
the bucket or any key (health is public through the tunnel):
"backup": {
"configured": true,
"status": "ok",
"provider": "r2",
"retention_days": 7,
"last_success": "2026-10-13T03:00:04Z",
"last_error": null,
"last_size_bytes": 1843200,
"next_at": "2026-10-14T03:00:00Z",
"running": false
}
| Field | Meaning |
|---|---|
configured | RUGEN_BACKUP_S3 is set and valid. |
status | off, misconfigured (reason in last_error), ok, or failing (the last attempt failed). |
provider | r2, aws or other, guessed from the host name. |
retention_days | RUGEN_BACKUP_RETENTION_DAYS. |
last_success | Time of the newest successful backup (also found in the bucket after a restart), or null. |
last_error | Short reason of the last failure (PUT: HTTP 403 AccessDenied, LIST: network error), or null. |
last_size_bytes | Compressed size of the last backup. |
next_at | When the next automatic backup runs. |
running | A backup is in progress. |
Restore from S3
The server must be stopped (Dokploy: Stop): the database file is swapped on disk. Then run the image once against the volume:
# type or paste the URL without leaving it in the shell history
read -rs RUGEN_BACKUP_S3 && export RUGEN_BACKUP_S3
docker run --rm -e RUGEN_BACKUP_S3 -v rugen_rugen-data:/data rugen-server:local --restore latest
Instead of latest, pass a backup name or key from
GET /v1/admin/backups (rugen-backup-20261013T030000Z-0.6.0 or
backups/db/2026/10/rugen-backup-20261013T030000Z-0.6.0.db.zst). The
restore downloads the backup, checks its sha256 against the manifest and
SQLite’s integrity check, keeps the old database as
rugen.db.<time>.bak (with its -wal / -shm), and moves the restored
one in. A backed-up signing key and the packages the restored database
knows are restored too (an existing key is kept as .bak). Start the
server again; migrations of a newer version apply on start.
Local backups
# consistent online copy, from inside the container (no sqlite3 needed)
docker compose exec rugen-server /rugen-server --backup /data/backup.db
docker compose cp rugen-server:/data/backup.db ./rugen-$(date +%F).db
# or with sqlite3 on the host, against the volume directory
sqlite3 /var/lib/docker/volumes/rugen_rugen-data/_data/rugen.db ".backup rugen.db.bak"
To restore a local copy: stop the stack, copy the backup over rugen.db
in the volume (delete rugen.db-wal and rugen.db-shm), start again.
Schema migrations are embedded and applied on start; a state.json from
the old JSON store is imported once automatically.
Updating
- Dokploy: Redeploy pulls the new
latest. Or pinRUGEN_IMAGEto a version tag and change it. - Plain Docker:
docker compose pull && docker compose up -d
Releases: pushing a v* tag to rugen-server builds and pushes the image
(amd64; run the workflow manually with arm64 ticked for ARM servers).
Updating to the 0.6 server
The server for rugen 0.6 serves 0.5 and 0.6 players side by side (lobby API 4 and 5), so updating it never locks anyone out. Nothing needs to be configured:
- Players of the two versions never meet: the queues pair equal versions only, and a room only takes players and spectators of its host’s version. Accounts, ratings, seasons and the leaderboard are shared. See Mixed versions.
- Packages already on the volume (
packages/*.rgpk) keep being served to 0.5 players; 0.6 uploads land next to them as.rgc/.rgs. - The same character has a different fingerprint in the two versions, so a
blocked 0.5 fingerprint does not cover its
.rgc: block it again by its 0.6 fingerprint. - Room names now keep apostrophes (
AXEL'S ROOMno longer turns intoAXELS ROOM). - The database schema is migrated on start; back it up first.
Password resets
Named accounts have no e-mail, so the operator is the only way back in for a player who lost their password (see Accounts). It works while the server runs:
docker compose exec rugen-server /rugen-server --data /data --reset-password axel
password of axel (account <id>) reset; every device was logged out
temporary password: <12 characters>
give it to the player privately; they should change it from PROFILE
The temporary password is printed once and never logged. Hand it over privately and have the player change it from PROFILE → CHANGE PASSWORD. Check who is asking first: usernames are public.
With RUGEN_ADMIN_TOKEN set, the same reset is also available over HTTP
(POST /v1/admin/reset_password with {"token": "...", "username": "axel"}, answering {"username", "password"}); without the token that
route is disabled.
Seasons and replays
Ranked seasons roll every 90 days with a soft rating reset; nothing needs
to be done by hand. At the end of a season the server stores its final
standings (seasons and season_results tables, in every backup) and each
player’s badge, then pulls every rating halfway toward 1200 and restarts the
records. GET /leaderboard?season=N serves a finished season’s standings
(the response lists the kept seasons in past, the last 12).
GET /leaderboard?fighter=<fingerprint> (or ?fighters=1 for the most
played fighter) serves a per-fighter board, kept per season in the
fighter_ratings table.
To end the running season early (a new server that should start its first
real season now, say), call POST /v1/admin/season_end with the admin
token: it answers the new season. It does exactly what the 90-day roll does.
curl -X POST -H "Authorization: Bearer $RUGEN_ADMIN_TOKEN" https://play.example.com/v1/admin/season_end
The server keeps the latest 2000 ranked input streams as
replays, and keeps the packages they need for RUGEN_PKG_REPLAY_TTL hours.
Website hooks: account links and hosted tournaments
The community site (rugen.dev) talks to the server with the admin token. Two things need it: tying a game account to a site login, and running a bracket the site announces. Both are server 0.7.1+.
Linking a game account
The player asks the game for a code (PROFILE → LINK WEBSITE), types it on the site, and the site redeems it. The code is 6 characters from the room-code alphabet, lives 10 minutes in the server’s memory (a restart forgets it), and a new request replaces the account’s previous one.
| Call | Body | Answer |
|---|---|---|
POST /v1/account/link_code (the game, with its key) | {"key": "…"} | {"code": "K7MXQ4", "expires_at": 1760540000, "expires_in": 600} (expires_at is Unix seconds) |
POST /v1/admin/link (the site, admin token) | {"token": "…", "code": "K7MXQ4"} | {"account_id": 42, "username": "axel", "profile": ProfileInfo}; 404 for an unknown, expired or already used code |
username is "" for an anonymous account (one that never claimed a
name). profile is the same ProfileInfo as GET /profile/{id} (name,
avatar, rating, record, rank, badge). The code is consumed by the redeem;
link_code is rate limited like the other /v1/account/* calls.
Server-hosted tournaments
A tournament the site organises has no host in the room: the server hosts it, the site hands out the room code, and the players enter it in the game (ONLINE → ROOMS → JOIN BY CODE; a public room is also listed in ROOMS). Entrants take their seat whenever they arrive; a pair is called once both its players are in the room (one match at a time, bracket order, the higher seed is P1). A pair whose one player has been waiting alone for 3 minutes is that player’s walkover; a pair with nobody there waits. A called match that does not start in 3 minutes, or whose player leaves, is decided as in a player-hosted bracket (see Tournament brackets). The room closes when the site cancels it or after 6 hours.
| Call | Body | Answer |
|---|---|---|
POST /v1/admin/tournament | {"token": "…", "size": 8, "name": "Friday Cup", "public": true, "rules": {"life": 5000, "rounds": 2, "round_time": 99}, "entrants": [42, 17, 9, 58], "seed": "order"} | {"code": "K7MXQ", "tournament": TournamentView} |
GET /room/{code} (no key) | The room’s public view: code, name, public, rules, ready, match_id, members (profile and role, no pings), tournament (TournamentView: size, state, entrants with names, seeds and ratings, rounds, live, champion) and server_hosted: true; 401 for an ordinary room without a key | |
POST /v1/admin/tournament/{code}/cancel | {"token": "…"} | {"code": "K7MXQ", "cancelled": true}; the members are told the room closed; 409 for a room a player hosts |
sizeis8or16(400otherwise);entrantsare 2 tosizeaccount ids, each once, each existing (404names none); the empty places are byes for the top seeds.seedis"order"(default: the first id is seed 1) or"rating"(by the server’s rating, ties by position).rulestakes the room rules (rounds,round_time,mode,chars,stage,fighter_size,life), with the usual defaults and clamping. Unknown fields are ignored.nameis cleaned like a room name (24 characters);publicdefaults totrue. There is no password: the code is the invitation.- Poll
GET /room/{code}to mirror the bracket; the server advances it on its own every few seconds.
curl -X POST -H "Authorization: Bearer $RUGEN_ADMIN_TOKEN" https://play.example.com/v1/admin/tournament \
-d '{"size": 8, "name": "Friday Cup", "entrants": [42, 17, 9, 58]}'
curl https://play.example.com/room/K7MXQ
Live match logs
Every match the server starts keeps an input log in memory for viewers
(GET /v1/live, GET /v1/live/{id}?from=N). Players feed it on their relay
session, each only its own half of every frame. It is bounded: 15 minutes
per match and RUGEN_LIVE_MB (default 64) for all matches together; past
either limit the server simply stops keeping that match’s log. A finished
match’s log is dropped 15 minutes after its relay session closed (unless a
player shared it as a replay, see below). /admin/stats shows live_logs
and live_bytes.
Shared replays
A player shares a finished match with POST /v1/replays; the code is served
to anyone by GET /v1/replays/{code} (a binary stream: the match header and
every frame). Shared replays live in the database (shared_replays, so
every backup holds them; GET /v1/admin/backup/status counts them as
shared_replays), with the packages they need kept as long. They are
bounded by RUGEN_REPLAY_DAYS (30) and RUGEN_REPLAY_MB (256, the oldest
go first when the total is over), swept every 10 minutes, and an account
shares at most 50 matches a day.
Something wrong on this page? Edit it on GitHub.