项目作者: code-lts

项目描述 :
Backup your MySQL/MariaDB server ( structure, data, users, grants, views, triggers, routines, events )
高级语言: Shell
项目地址: git://github.com/code-lts/sql-backup.git
创建时间: 2018-04-06T18:13:52Z
项目社区:https://github.com/code-lts/sql-backup

开源协议:Other

下载


sql-backup - Backup your MySQL / MariaDB server !

Codacy Badge
Actions Status
codecov
License: Unlicense
FOSSA Status
CII Best Practices

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

Install

Clone the repository

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

Unzip file

  1. unzip sql-backup.zip

Move into the directory

  1. cd sql-backup-1.2.0/

Copy the configuration example

  1. cp .env.dist .env

Edit your configuration file

Nano

  1. nano .env

Vi

  1. vi .env

Start backup

Execute this command to start the backup !

  1. ./backup.sh

Extras

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

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

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

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

Options

NAME DEFAULT VALUE OPTIONAL
BACKUP_DIR NO
MYSQL_HOST NO
MYSQL_USER NO
MYSQL_PASS YES
MYSQL_PORT 3306 YES
SKIP_DATABASES YES
EXPERT_ARGS —default-character-set=utf8 —extended-insert=FALSE —single-transaction —skip-comments —skip-dump-date —hex-blob —tz-utc YES
ON_SUCCESS YES
SKIP_OP YES

ON_SUCCESS is called on script success

Example .env

  1. BACKUP_DIR=/sql_backup
  2. MYSQL_HOST=localhost
  3. MYSQL_USER=root
  4. MYSQL_PASS=root
  5. MYSQL_PORT=3306
  6. SKIP_DATABASES=mysql,sys,information_schema,performance_schema,phpmyadmin
  7. SKIP_OP=users,grants

Files

NAME DESCRIPTION
database.sql All the data
structure.sql The structure of the databases and tables
grants.sql The grants for all users except root
events.sql The scheduled events
views.sql The views
triggers.sql The triggers
routines.sql All the procedures & functions
users.sql All MySQL users

License

FOSSA Status