Skip to content

Repository files navigation

sql-backup - Backup your MySQL / MariaDB server !

Codacy BadgeActions StatuscodecovLicense: UnlicenseFOSSA StatusCII Best Practices

Backup your MySQL / MariaDB server ( structure, data, users, grants, views, triggers, routines, events )

Install

Clone the repository

curl -L -# -o sql-backup.zip https://github.com/code-lts/sql-backup/archive/refs/tags/v1.2.0.zip

Unzip file

unzip sql-backup.zip

Move into the directory

cd sql-backup-1.2.0/

Copy the configuration example

cp .env.dist .env

Edit your configuration file

Nano

nano .env

Vi

vi .env

Start backup

Execute this command to start the backup !

./backup.sh

Extras

To use an external env file in a custom location, example :

export BACKUP_CONFIG_ENVFILE="/home/myuser/secretbackupconfig.env.txt"
./backup.sh
unset BACKUP_CONFIG_ENVFILE

You can use the variables of the env file in the ON_SUCCESS variable, example :

ON_SUCCESS="${BACKUP_DIR}/onsuccessscript.sh"

Options

NAMEDEFAULT VALUEOPTIONAL
BACKUP_DIRNO
MYSQL_HOSTNO
MYSQL_USERNO
MYSQL_PASSYES
MYSQL_PORT3306YES
SKIP_DATABASESYES
EXPERT_ARGS--default-character-set=utf8 --extended-insert=FALSE --single-transaction --skip-comments --skip-dump-date --hex-blob --tz-utcYES
ON_SUCCESSYES
SKIP_OPYES

ON_SUCCESS is called on script success

Example .env

BACKUP_DIR=/sql_backup
MYSQL_HOST=localhost
MYSQL_USER=root
MYSQL_PASS=root
MYSQL_PORT=3306
SKIP_DATABASES=mysql,sys,information_schema,performance_schema,phpmyadmin
SKIP_OP=users,grants

Files

NAMEDESCRIPTION
database.sqlAll the data
structure.sqlThe structure of the databases and tables
grants.sqlThe grants for all users except root
events.sqlThe scheduled events
views.sqlThe views
triggers.sqlThe triggers
routines.sqlAll the procedures & functions
users.sqlAll MySQL users

License

FOSSA Status

About

Backup your MySQL/MariaDB server ( structure, data, users, grants, views, triggers, routines, events )

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages