FiveM Server Backups: What to Save, How Often, and How to Restore


Most FiveM servers do not lose data because of hackers. They lose it because of a bad update, a dropped table, a dead VPS disk or an admin who ran the wrong SQL query at 2 a.m. A working backup plan turns those events into a 15-minute inconvenience instead of a wipe. This guide covers what to back up, how to automate it, and how to prove your backups actually restore.
What actually needs backing up
A FiveM server is a few distinct pieces, and each one fails in a different way. Treat them separately.
- The database. This is the only thing you cannot rebuild. Characters, money, inventories, vehicles, houses, job grades and bans all live in MariaDB or MySQL, whether you run QBCore, ESX or Qbox. If you only back up one thing, back up this.
- Your server-data folder. The
resourcesdirectory with every script you installed and every config you edited, plusserver.cfg. You can technically re-download scripts, but rebuilding months of config tweaks from memory is not realistic. - Secrets. Your license key, database connection string, RCON password if you use one, and any API keys or webhooks. These usually sit inside
server.cfgor a file it executes. - txAdmin data. The
txDatafolder holds txAdmin's own configuration, admin accounts and its player database (warnings, bans, notes). Its location depends on how you launched txAdmin, so find it once and write the path down.
What you can skip: the cache folder inside your server-data directory. FXServer regenerates it, it is large, and restoring a stale cache can cause more confusion than it solves. The server artifacts themselves are also replaceable, but note which artifact build you were running so you can return to it if an update breaks something.
Database dumps done properly
Copying the raw MariaDB data directory while the database is running is a common mistake and can give you a corrupted copy. Use a logical dump instead. For InnoDB tables, which is what modern framework schemas use, --single-transaction gives you a consistent snapshot without locking the server while players are online.
mysqldump --single-transaction --routines --triggers \
--default-character-set=utf8mb4 fivem | gzip > fivem_2024-01-01.sql.gzA few details that matter:
- Character set. Player names and item labels often contain non-ASCII characters. Dumping with
utf8mb4avoids mangled names after a restore. - Credentials. Do not put the database password on the command line where it ends up in shell history. On Linux, put it in a
~/.my.cnffile owned by the backup user with permissions set to600. - Newer MariaDB. Recent MariaDB versions ship the same tool as
mariadb-dump. The flags above work the same way. - Windows hosts. Exporting from HeidiSQL is fine for a one-off, but it is manual and gets forgotten. Script it with the dump tool and Task Scheduler instead.
A simple automated backup script
Here is a minimal Linux script that dumps the database, archives the server-data folder without the cache, and deletes local copies older than two weeks. Adjust the paths and database name to your setup.
#!/bin/bash
set -euo pipefail
STAMP=$(date +%Y-%m-%d_%H%M)
DEST=/backups/fivem
DB=fivem
DATA=/home/fivem/server-data
mkdir -p "$DEST"
mysqldump --single-transaction --routines --triggers \
--default-character-set=utf8mb4 "$DB" | gzip > "$DEST/db_$STAMP.sql.gz"
tar --exclude='./cache' -czf "$DEST/files_$STAMP.tar.gz" -C "$DATA" .
find "$DEST" -type f -mtime +14 -deleteSchedule it with cron. Running it shortly before your daily txAdmin scheduled restart works well, because the restart then starts from the state you just saved:
30 4 * * * /home/fivem/backup.shAdd the txData folder to the tar step, or to a second archive, once you know its path.
Keep secrets out of shared copies
Backups get copied to more places than your live server: cloud storage, a co-owner's laptop, a Git repository. Each copy is a chance to leak your license key or database password.
A clean pattern is to move secrets into their own file and load it from server.cfg:
# server.cfg
exec secrets.cfg
ensure oxmysql
ensure qb-core
# secrets.cfg (never commit this file)
sv_licenseKey "your_key_here"
set mysql_connection_string "mysql://user:pass@localhost/fivem"Now server.cfg and your resources can go into a private Git repository with secrets.cfg listed in .gitignore, and you back up the secrets file separately, encrypted. Git also gives you something archives do not: a history of every config change, so you can see exactly what changed before things broke.
Store copies somewhere else
A backup on the same disk as the server protects you from a bad query, not from a dead machine or a host that suspends your account. Follow the usual 3-2-1 idea, scaled to a game server:
- Local copy on the server for fast restores after a mistake.
- Offsite copy pushed automatically to object storage or a different provider. Tools like
rcloneorrestichandle this and can encrypt before upload. - Occasional cold copy, for example a weekly download to a machine you control.
Restrict who can read the offsite bucket. A database dump contains every player identifier you store, so treat it with the same care as the live database.
When to take extra backups
Daily automated backups cover normal operation. Take a manual one, and label it clearly, before any of these:
- Updating server artifacts.
- Updating your framework core or a large resource such as an inventory, housing or garage system.
- Running any SQL file that ships with a new script, especially ones that
ALTERorDROPtables. - Bulk admin actions: economy resets, mass item removals, character wipes.
- Migrating hosts or moving between frameworks.
A dump named db_before-inventory-update.sql.gz is worth far more in a crisis than the fifth file with a timestamp you have to guess at.
Test the restore, not just the backup
An untested backup is a guess. Do a restore drill at least once, and again whenever you change the script. The safest way is to restore into a separate database so you never touch live data:
mysql -e "CREATE DATABASE fivem_restore CHARACTER SET utf8mb4"
gunzip -c /backups/fivem/db_2024-01-01_0430.sql.gz | mysql fivem_restoreThen check it like you mean it:
- Row counts on your players or users table roughly match production.
- A known character's money, inventory and owned vehicles look correct.
- Names with special characters display properly.
- Extract the file archive on a test machine, point a copy of the server at
fivem_restoreusing a separate license key, and confirm it boots and you can log in.
Time the whole process. Knowing that a full restore takes 20 minutes lets you make calm decisions during an outage instead of improvising. Write the steps in a short document your other admins can follow without you.
Rolling back a single mistake
Not every problem needs a full restore. If one player's inventory was wiped by a bug, restoring the whole database would roll back everyone else's progress since the last dump. Instead, load the backup into fivem_restore, query the affected rows there, and copy only those values back to production. This is another reason to keep restoring to a separate database as your default habit.
Practical takeaway
- Back up the database daily with a consistent dump, compressed and dated.
- Archive server-data and
txData, excludingcache. - Move secrets into their own file and keep them out of Git and shared copies.
- Push encrypted copies offsite automatically.
- Take a labelled manual backup before every update or SQL change.
- Run a restore drill into a separate database and write the steps down.
If you are still setting up the server itself, the official FiveM server manual covers artifacts and txAdmin. Put the backup script in place on day one, before your players have anything to lose.