Shopping Cart
FiveM script 11abac85b780a6bfb422bb414511bacab31e72a7

How to set up automatic database backups – Server Tutorials


Today I will be showing how to set up automatic database backup without installing additional scripts to your FiveM server.

This method has only been tested on Windows but the thread contains a LINUX CRON job guide, feedback is appreciated.

Required

  • Server with remote access ( Remote desktop connection for Windows, Putty for Linux )
  • MySQL [ Windows / Linux ]
  • SQL client ( HeidiSQL )
  • Notepad++ or any other editing tool

Used in this example

  • Windows server 2019
  • MySQL 8.0

Log in to your SQL server using your SQL client, in this case I will be using HeidiSQL


FiveM script gCNReK0


When Heidi connects to the server, select “Query” tab.
It should be the first tab to the right of the server tab.


FiveM script majOzlc

Copy&Paste the query below into the text field and then change ‘username’, ‘password’ and ‘yourdatabase’ to values you want.


CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
GRANT PROCESS ON *.* TO `newuser`@`localhost`;
GRANT SELECT ON `yourdatabase`.* TO `newuser`@`localhost`;

Hit F9 or the blue play button to run your query.


Create a new folder called “fiveMbackup” in the root of your C: drive (C:fiveMbackup) or anywhere you want (you will have to change parameters in code below).

Scroll down if you are using Linux.

Open N++, create a new file, add:

cd C:Program FilesMySQLMySQL Server 8.0bin
mysqldump -uexampleusername -pexamplepassword yourdatabase --single-transaction --quick --lock-tables=false > C:fiveMbackupfiveMbackup_%date:~-10,2%-%date:~-7,2%-%date:~-4,4%.sql
QUIT

Do not remove -u and -p from uexampleusername -pexamplepassword!
Change only the text after -u and -p!

Save as .bat inside the folder you created.

Test your .bat file, if everything is working right you should see a new file in the folder called “fiveMbackup_MM_DD_YYYY.sql”.


WINDOWS
Open Task Sheduler and create a new basic task (follow steps on .GIF below)

FiveM script f1JaaXW

LINUX (source)

Open terminal and type:

sudo tcsh
nano /etc/crontab

Add the following line will schedule the backup at 1 AM each day, change the parameters to the ones you will be using.

0 1 * * * /usr/local/mysql/bin/mysqldump -uroot -ppassword --opt database > /path/to/directory/filename.sql

Helpful CRON documentation.


That’s it, you’re done!
You can test if your task works by right clicking the task in Task Scheduler and clicking “Run”.

Thank you for reading, if you need help with setting this up please post a reply in the thread!



Premium ESX Scripts? Click here!

Leave a Reply
FiveM ESX Scripts

The best scripts and maps

Best support

Problems? We are there to help!

Wide range of products

We have a wide range of products

100% Secure Checkout

Stripe

About

Are you creating a FiveM server? Here are the best scripts for it – for a cheap price and a very good quality! Don’t waste time testing and fixing free scripts. Use our premium FiveM scripts.

ESX Scripts is a Network for FiveM Scripts | FiveM Store | FiveM Mods | FiveM Scripts | FiveM EUP | FiveM Cheats | FiveM AntiCheats | FiveM Vehicles | FiveM Cars | FiveM Maps | FiveM Discord | FiveM Clothes | FiveM Launcher | FiveM Servers | FiveM.NeT | FiveM | FiveM RP | FiveM RolePlay | FiveM USA | FiveM Europe | FiveM EU | roleplay store | Role Play | RP | RP Server | FiveM Asia | FiveM World | FiveM Servers | FiveM Tools FiveM Hosting | FiveM Shop | CitizenFX Collective | FiveM CFX, ESX Scripts A global network that aims to strengthen fivem.net roleplay servers. And it’s just to improve the quality of the servers.  We hope we can get your opinion just to improve the quality of your server. You can get maps, vehicles, scripts, eup, tools, etc… right on our shop website!

Help

Need help with a product? Our sellers offer good support. Free for you! Click here to get help.

Are you a creator?

We are looking for people that want to sell their scripts and maps (of FiveM) in our store. Click here to register and sell.