Naum Soloveychik 63c669ccbf Update README.md
2020-01-11 00:06:00 +03:00
2020-01-10 23:59:01 +03:00
2020-01-11 00:06:00 +03:00

MySQL backup script

Feature rich MySQL / MariaDB backup script.

Installation

  • git clone https://github.com/1sept/mysql_backup.git
  • set database user and password in .my.cnf located in user homedir.

Example

Usage: mysql_backup.sh -d /backup/dir/ -n daily [-c 10 -s -z -e test@domain.org]

Options

-d , --dir
backup directory
-n, --name
backup name
-c, --copies
number of copies to store (default 10)
-e, --email
email to send notifications
-l, --lock-all-tables
lock all tables across all databases. This is achieved by acquiring a global read lock for the duration of the whole dump. This option automatically turns off --single-transaction and --lock-tables. WARNING!!! This will block all applications. -s, --single-transaction
this option sets the transaction isolation mode to REPEATABLE READ and sends a START TRANSACTION SQL statement to the server before dumping data. It is useful only with transactional tables such as InnoDB, because then it dumps the consistent state of the database at the time when START TRANSACTION was issued without blocking any applications.
-z, --compress
compress dump using gzip
-q, --quiet
-h, --help

Setup script in crontab

20 01 * * * root /bin/sh /path/to/mysql_backup.sh -d /backup/dir/ -n daily -c 10 -e admin@email.com -z -q

.my.cnf example

    [mysqldump]
    user = mysqldump
    password = secret_passwd_here
    host = localhost
    max-allowed-packet=512M
Description
Feature rich MySQL / MariaDB backup script.
Readme 91 KiB
Languages
Shell 100%