Backups
Take backups while players keep playing, look inside any of them, and restore table by table with a safety copy taken first.
Taking a backup
Backups are consistent snapshots taken without locking tables, so players keep playing. You can back up all tables or only some.
- Open
/sqlmenu→ Maintenance → Backups. - Under Create a backup, add a note if you like ("before the inventory update"). Turn on Only some tables to pick tables; otherwise every table is backed up.
- Press Create backup. A progress bar shows how far it is; the backup then appears in the list.
Each backup is one .sql.gz file: an ordinary .sql file, compressed. They are kept in the waw-sql-backups folder in your server's data folder (the folder that holds server.cfg); the panel shows the exact path under the list. Copy them somewhere else now and then, so a broken disk does not take your backups with it.
Automatic backups
Automatic backups run every N hours. The defaults: every 6 hours, keep the last 20, delete after 14 days. The schedule saved in the panel is stored in waw-sql-backups/schedule.json.
Only automatic backups are deleted when they pass the "keep last" or "delete after N days" limits. Manual, before-restore and before-optimization backups are never deleted automatically.
Restoring
In the list, press Restore on a backup, tick the tables to bring back and press Restore selected tables. Only the ticked tables change; the others stay as they are. Restoring replaces those tables with their content from the backup, so it is best done while no players are online.
Behind the scenes it works table by table:
- A safety backup of the current state is taken first.
- Each table is loaded into a temporary table.
- The temporary table is swapped in with one
RENAME TABLE.
If anything fails, the live table is left untouched. Tables that use foreign keys cannot be swapped; they are restored in place, and the safety backup is your way back.
Restoring without the panel
If the server no longer starts, you can load a backup by hand with HeidiSQL (it comes with MariaDB on Windows; see Connecting your database).
- Stop the server.
- Copy the backup out of the
waw-sql-backupsfolder and unpack it with 7-Zip (right-click → 7-Zip → Extract Here). You get a.sqlfile. - In HeidiSQL, connect, click your server's database on the left, then use File → Run SQL file and pick the
.sqlfile.
Each table in the backup is deleted and made again with the backup's rows. Everything written to those tables after the backup was taken is lost, and no safety copy is made. If the server still starts, restore from the panel instead.
Looking inside a backup
Contents shows what is inside a backup without restoring anything:
- every table with its rows and size, largest first
- the rows of a table, 50 at a time, with a search (a name, a citizen ID, a plate) in all columns or one; any value opens in full
- a table compared with the database today: rows changed (old and new value side by side), rows gone since, rows new since
- a player compared with today, by citizen ID, licence or name: every table that holds player data, money and inventory compared value by value, item by item. A player deleted since the backup still shows what they had
It only reads: the backup file, and for a comparison the current rows with SELECT. It needs the "Look inside a backup" permission (backups.inspect), which is separate from seeing the list. Every look is written to the console and the Discord log, once per person, backup and table or player in 10 minutes.
Secret values are never shown, searched or compared by value: columns named like a password, key or token (password, api_key, access_token, webhook_url...), the values of settings tables (tables whose name ends in settings, config or secrets, where scripts keep their API keys and webhooks), and any Discord webhook address inside a value. A comparison still tells you that such a value changed.
Large files are read in the background with a progress bar, one at a time, so the server keeps running smoothly. Tables over 24 MB (waw_sql_view_cache_mb) are read from the file for each page and cannot be compared; neither can a table that has grown past twice that size since the backup. At most 4 reads wait in line; beyond that the panel asks you to wait.
Backups from other scripts
This lets another script ask for a backup through the backupCreate export, for example before it changes many rows. It is off by default; switch it on under Backups → Backups from other scripts.
When it is on, scripts can take at most one backup every 10 minutes, and only their last 10 backups are kept. Players cannot trigger this themselves; only code running on the server can ask. Leave it off unless a script you trust needs it. Developers: see Exports & events.
Settings
| convar | default | meaning |
|---|---|---|
waw_sql_backup_path | waw-sql-backups | backup folder, relative to the server data folder |
waw_sql_auto_backup | false | turn automatic backups on until the schedule is saved in the panel |
waw_sql_view_cache_mb | 24 | tables larger than this are read from the file page by page when you look inside a backup |
