Back up your FiveM server automatically
Schedule backups of your FiveM server folder and database: contents, cron script and restore procedure.
Back up your FiveM server automatically
A disk failure, a resource that corrupts the database, or a bad manipulation is enough to lose weeks of progress. Automatic backups protect both the server files and the player data.
Cause / The problem
Data loss happens when no backup plan is in place, when the database is not dumped (only files are copied), or when backups stay on the same machine as the server and disappear with it.
Solution
- Use your host’s backup feature if one exists: most panels offer a daily server snapshot. Turn it on and check the frequency.
- Identify what to back up: the
resources/folder,server.cfg,server-data/, and especially a database dump (MySQL/MariaDB). Without that dump, accounts and vehicles are lost. - Create a cron script (Linux) that dumps the database and archives the files:
#!/bin/bash DATE=$(date +%Y%m%d-%H%M) mysqldump -u fivem -p"PASSWORD" esx_db > /backups/db_$DATE.sql tar -czf /backups/server_$DATE.tar.gz /srv/fivem/server-data /srv/fivem/resources find /backups -mtime +7 -delete - Schedule it in the crontab:
0 4 * * * /srv/fivem/backup.sh - Send backups off-site. Copy the archive to external storage (S3, FTP, another VPS) — a backup on the same machine does not protect against a disk failure.
- Test the restore. An untested backup is no backup at all. Restore on a test server: extract the archive, import the SQL dump (
mysql ... < db.sql) and start the server to verify.
Keep at least 7 days of retention plus an older weekly backup so you can roll back after a slow corruption.