Restarts, backups and updates
In short
Stable servers are boring on purpose: fixed restart times, automatic backups, a test server for updates and a written rollback plan.
| When | Routine |
|---|---|
| Every restart | Save player data in txAdmin’s restart and shutdown events |
| Daily | Database dump, compressed and copied off the machine |
| Weekly | Disk space, txAdmin diagnostics, resmon on a busy evening |
| Every update | Test on a dev server, back up, deploy in a quiet hour, keep the old version |
| Monthly | Restore a backup to a spare database to prove it works |
AddEventHandler('txAdmin:events:scheduledRestart', function(data)
if data.secondsRemaining == 60 then
-- save everything that is not saved yet
end
end)
AddEventHandler('txAdmin:events:serverShuttingDown', function()
-- final save
end)txAdmin announces a scheduled restart 30, 15, 10, 5, 4, 3, 2 and 1 minutes before it happens, and restarts crashed servers automatically.
#!/bin/sh
STAMP=$(date +%F-%H%M)
mariadb-dump --single-transaction fivem | gzip > /backups/fivem-$STAMP.sql.gz
tar --exclude='server-data/cache' -czf /backups/server-data-$STAMP.tar.gz -C /home/fivem server-data
find /backups -type f -mtime +14 -delete- Read the artifact changelog, then update the test server first.
- Keep the previous artifact folder — rolling back is switching folders.
- Update one resource at a time and watch the console after each.
- Copy backups off the machine; a backup on the same disk dies with it.