A basic script to backup mysql instance
Go to file
Dryusdan 54305537a3 Add cifs support for hetzner storagebox 2023-12-28 14:23:59 +01:00
LICENSE Initial commit 2020-02-15 11:22:57 +01:00
README.md Update README 2023-10-03 12:27:02 +02:00
mysqlbackup.sh Add cifs support for hetzner storagebox 2023-12-28 14:23:59 +01:00

README.md

MySQL Backup

A basic script to backup mysql instance

How it work

MySQL backup list your databases. On each database, MySQL Backup lists tables, dumps schemas and data on two separate files on each tables.

In databases folder, you will find the structure for each database and each table. In extras folder, you will find the routine, trigger and event of your database. In schemas folder, you will find each table structure per file. In datas folder, you will find each table data per file.

You need to configure a user with somes permissions like this :

For all tables :

*.*:SELECT,SHOW VIEW,RELOAD,REPLICATION CLIENT,EVENT,TRIGGER,LOCK TABLES

For sys table (MariaDB 10.11 on Debian 12) :

sys.*:LOCK TABLES,SHOW VIEW,EXECUTE

How use it ?

Create a backup user with these grants : SELECT, RELOAD, LOCK TABLES, REPLICATION CLIENT, SHOW VIEW, EVENT, TRIGGER

Download mysqlbackup.sh. Execute script with good parameters Take a coffee

su - mysqlbackup
cd ~
wget https://git.drycat.fr/Dryusdan/mysql-backup/raw/branch/master/mysqlbackup.sh
chmod +x mysqlbackup.sh
./mysqlbackup.sh /empty/folder/for/mysqldump 7 backup S3c4ET 127.0.0.1
Parameters Explain
Folder Folder where dumps were stored. This folder must be empty
Retention Time on the day before dropping a dump
Username Username of you're mysql's backup user
Password Password of you're mysql's backup user
Host You're MySQL Host. Default is 127.0.0.1
Port You're MySQL Port. Default is 3306