mirror of
https://github.com/tiredofit/docker-db-backup.git
synced 2025-12-21 21:33:28 +01:00
feat - add MySQL Event backup support
This commit is contained in:
33
README.md
33
README.md
@@ -257,16 +257,18 @@ If these are set and no other defaults or variables are set explicitly, they wil
|
||||
|
||||
###### MariaDB/MySQL
|
||||
|
||||
| Variable | Description | Default | `_FILE` |
|
||||
| ---------------------------------- | --------------------------------------------------------------------------------------------------------- | ------------------------- | ------- |
|
||||
| `DEFAULT_PORT` | MariaDB Port | `3306` | x |
|
||||
| `DEFAULT_EXTRA_BACKUP_OPTS` | Pass extra arguments to the backup command only, add them here e.g. `--extra-command` | | |
|
||||
| `DEFAULT_EXTRA_ENUMERATION_OPTS` | Pass extra arguments to the database enumeration command only, add them here e.g. `--extra-command` | | |
|
||||
| `DEFAULT_EXTRA_OPTS` | Pass extra arguments to the backup and database enumeration command, add them here e.g. `--extra-command` | | |
|
||||
| `DEFAULT_MYSQL_MAX_ALLOWED_PACKET` | Max allowed packet if backing up MySQL / MariaDB | `512M` | |
|
||||
| `DEFAULT_MYSQL_SINGLE_TRANSACTION` | Backup in a single transaction with MySQL / MariaDB | `TRUE` | |
|
||||
| `DEFAULT_MYSQL_STORED_PROCEDURES` | Backup stored procedures with MySQL / MariaDB | `TRUE` | |
|
||||
| `DEFAULT_MYSQL_ENABLE_TLS` | Enable TLS functionality for MySQL/MariaDB client | `FALSE` | |
|
||||
| Variable | Description | Default | `_FILE` |
|
||||
| ---------------------------------- | --------------------------------------------------------------------------------------------------------- | ------- | ------- |
|
||||
| `DEFAULT_PORT` | MySQL / MariaDB Port | `3306` | x |
|
||||
| `DEFAULT_EXTRA_BACKUP_OPTS` | Pass extra arguments to the backup command only, add them here e.g. `--extra-command` | | |
|
||||
| `DEFAULT_EXTRA_ENUMERATION_OPTS` | Pass extra arguments to the database enumeration command only, add them here e.g. `--extra-command` | | |
|
||||
| `DEFAULT_EXTRA_OPTS` | Pass extra arguments to the backup and database enumeration command, add them here e.g. `--extra-command` | | |
|
||||
| `DEFAULT_MYSQL_EVENTS` | Backup Events | `TRUE` | |
|
||||
| `DEFAULT_MYSQL_MAX_ALLOWED_PACKET` | Max allowed packet | `512M` | |
|
||||
| `DEFAULT_MYSQL_SINGLE_TRANSACTION` | Backup in a single transaction | `TRUE` | |
|
||||
| `DEFAULT_MYSQL_STORED_PROCEDURES` | Backup stored procedures | `TRUE` | |
|
||||
| `DEFAULT_MYSQL_ENABLE_TLS` | Enable TLS functionality | `FALSE` | |
|
||||
|
||||
| `DEFAULT_MYSQL_TLS_VERIFY` | (optional) If using TLS (by means of MYSQL_TLS_* variables) verify remote host | `FALSE` | |
|
||||
| `DEFAULT_MYSQL_TLS_VERSION` | What TLS `v1.1` `v1.2` `v1.3` version to utilize | `TLSv1.1,TLSv1.2,TLSv1.3` | |
|
||||
| `DEFAULT_MYSQL_TLS_CA_FILE` | Filename to load custom CA certificate for connecting via TLS | `/etc/ssl/cert.pem` | x |
|
||||
@@ -525,11 +527,12 @@ Otherwise, override them per backup job. Additional backup jobs can be scheduled
|
||||
| `DB01_NAME` | Schema Name e.g. `database` or `ALL` to backup all databases the user has access to. | | |
|
||||
| | Backup multiple by separating with commas eg `db1,db2` | | x |
|
||||
| `DB01_NAME_EXCLUDE` | If using `ALL` - use this as to exclude databases separated via commas from being backed up | | x |
|
||||
| `DB01_PORT` | MariaDB Port | `3306` | x |
|
||||
| `DB01_MYSQL_MAX_ALLOWED_PACKET` | Max allowed packet if backing up MySQL / MariaDB | `512M` | |
|
||||
| `DB01_MYSQL_SINGLE_TRANSACTION` | Backup in a single transaction with MySQL / MariaDB | `TRUE` | |
|
||||
| `DB01_MYSQL_STORED_PROCEDURES` | Backup stored procedures with MySQL / MariaDB | `TRUE` | |
|
||||
| `DB01_MYSQL_ENABLE_TLS` | Enable TLS functionality for MySQL/MariaDB client | `FALSE` | |
|
||||
| `DB01_PORT` | MySQL / MariaDB Port | `3306` | x |
|
||||
| `DB01_MYSQL_EVENTS` | Backup Events for | `TRUE` | |
|
||||
| `DB01_MYSQL_MAX_ALLOWED_PACKET` | Max allowed packet | `512M` | |
|
||||
| `DB01_MYSQL_SINGLE_TRANSACTION` | Backup in a single transaction | `TRUE` | |
|
||||
| `DB01_MYSQL_STORED_PROCEDURES` | Backup stored procedures | `TRUE` | |
|
||||
| `DB01_MYSQL_ENABLE_TLS` | Enable TLS functionality | `FALSE` | |
|
||||
| `DB01_MYSQL_TLS_VERIFY` | (optional) If using TLS (by means of MYSQL_TLS_* variables) verify remote host | `FALSE` | |
|
||||
| `DB01_MYSQL_TLS_VERSION` | What TLS `v1.1` `v1.2` `v1.3` version to utilize | `TLSv1.1,TLSv1.2,TLSv1.3` | |
|
||||
| `DB01_MYSQL_TLS_CA_FILE` | Filename to load custom CA certificate for connecting via TLS | `/etc/ssl/cert.pem` | x |
|
||||
|
||||
@@ -17,6 +17,7 @@ DEFAULT_FILESYSTEM_PERMISSION=${DEFAULT_FILESYSTEM_PERMISSION:-"700"}
|
||||
DEFAULT_FILESYSTEM_ARCHIVE_PATH=${DEFAULT_FILESYSTEM_ARCHIVE_PATH:-"${DEFAULT_FILESYSTEM_PATH}/archive/"}
|
||||
DEFAULT_LOG_LEVEL=${DEFAULT_LOG_LEVEL:-"notice"}
|
||||
DEFAULT_MYSQL_ENABLE_TLS=${DEFAULT_MYSQL_ENABLE_TLS:-"FALSE"}
|
||||
DEFAULT_MYSQL_EVENTS=${DEFAULT_MYSQL_EVENTS:-"TRUE"}
|
||||
DEFAULT_MYSQL_MAX_ALLOWED_PACKET=${DEFAULT_MYSQL_MAX_ALLOWED_PACKET:-"512M"}
|
||||
DEFAULT_MYSQL_SINGLE_TRANSACTION=${DEFAULT_MYSQL_SINGLE_TRANSACTION:-"TRUE"}
|
||||
DEFAULT_MYSQL_STORED_PROCEDURES=${DEFAULT_MYSQL_STORED_PROCEDURES:-"TRUE"}
|
||||
|
||||
@@ -188,6 +188,7 @@ bootstrap_variables() {
|
||||
transform_backup_instance_variable "${backup_instance_number}" LOG_LEVEL backup_job_log_level
|
||||
transform_backup_instance_variable "${backup_instance_number}" MONGO_CUSTOM_URI backup_job_mongo_custom_uri
|
||||
transform_backup_instance_variable "${backup_instance_number}" MYSQL_ENABLE_TLS backup_job_mysql_enable_tls
|
||||
transform_backup_instance_variable "${backup_instance_number}" MYSQL_EVENTS backup_job_mysql_events
|
||||
transform_backup_instance_variable "${backup_instance_number}" MYSQL_MAX_ALLOWED_PACKET backup_job_mysql_max_allowed_packet
|
||||
transform_backup_instance_variable "${backup_instance_number}" MYSQL_SINGLE_TRANSACTION backup_job_mysql_single_transaction
|
||||
transform_backup_instance_variable "${backup_instance_number}" MYSQL_STORED_PROCEDURES backup_job_mysql_stored_procedures
|
||||
@@ -516,6 +517,9 @@ backup_mssql() {
|
||||
}
|
||||
|
||||
backup_mysql() {
|
||||
if var_true "${backup_job_mysql_events}" ; then
|
||||
events="--events"
|
||||
fi
|
||||
if var_true "${backup_job_mysql_single_transaction}" ; then
|
||||
single_transaction="--single-transaction"
|
||||
fi
|
||||
@@ -547,7 +551,7 @@ backup_mysql() {
|
||||
compression
|
||||
pre_dbbackup $db
|
||||
write_log notice "Dumping MySQL/MariaDB database: '${db}' ${compression_string}"
|
||||
run_as_user ${play_fair} mysqldump --max-allowed-packet=${backup_job_mysql_max_allowed_packet} -h ${backup_job_db_host} -P ${backup_job_db_port} -u${backup_job_db_user} ${single_transaction} ${stored_procedures} ${mysql_tls_args} ${backup_job_extra_opts} ${backup_job_extra_dump_opts} $db | ${compress_cmd} | run_as_user tee "${TEMP_PATH}"/"${target}" > /dev/null
|
||||
run_as_user ${play_fair} mysqldump --max-allowed-packet=${backup_job_mysql_max_allowed_packet} -h ${backup_job_db_host} -P ${backup_job_db_port} -u${backup_job_db_user} ${events} ${single_transaction} ${stored_procedures} ${mysql_tls_args} ${backup_job_extra_opts} ${backup_job_extra_dump_opts} $db | ${compress_cmd} | run_as_user tee "${TEMP_PATH}"/"${target}" > /dev/null
|
||||
exit_code=$?
|
||||
check_exit_code backup $target
|
||||
timer backup finish
|
||||
@@ -565,7 +569,7 @@ backup_mysql() {
|
||||
compression
|
||||
pre_dbbackup all
|
||||
write_log notice "Dumping all MySQL / MariaDB databases: '$(echo ${db_names} | xargs | tr ' ' ',')' ${compression_string}"
|
||||
run_as_user ${play_fair} mysqldump --max-allowed-packet=${backup_job_mysql_max_allowed_packet} -h ${backup_job_db_host} -P ${backup_job_db_port} -u${backup_job_db_user} ${single_transaction} ${stored_procedures} ${mysql_tls_args} ${backup_job_extra_opts} ${backup_job_extra_dump_opts} --databases $(echo ${db_names} | xargs) | ${compress_cmd} | run_as_user tee "${TEMP_PATH}"/"${target}" > /dev/null
|
||||
run_as_user ${play_fair} mysqldump --max-allowed-packet=${backup_job_mysql_max_allowed_packet} -h ${backup_job_db_host} -P ${backup_job_db_port} -u${backup_job_db_user} ${events} ${single_transaction} ${stored_procedures} ${mysql_tls_args} ${backup_job_extra_opts} ${backup_job_extra_dump_opts} --databases $(echo ${db_names} | xargs) | ${compress_cmd} | run_as_user tee "${TEMP_PATH}"/"${target}" > /dev/null
|
||||
exit_code=$?
|
||||
check_exit_code backup $target
|
||||
timer backup finish
|
||||
|
||||
Reference in New Issue
Block a user