From 83ee72706eff40e08af23c5e808479c6caf6d068 Mon Sep 17 00:00:00 2001 From: Naum Soloveychik Date: Sun, 12 Jan 2020 11:11:47 +0300 Subject: [PATCH] added xz compress option --- README.md | 4 +++- mysql_backup.sh | 23 ++++++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2e39b80..2058ff1 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,10 @@ lock all tables across all databases. This is achieved by acquiring a global rea 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** +**-z, --gzip** compress dump using gzip +**-x, --xz** +compress dump using xz **-m, --master** set master data in dump **-q, --quiet** diff --git a/mysql_backup.sh b/mysql_backup.sh index 73b9630..2a42030 100755 --- a/mysql_backup.sh +++ b/mysql_backup.sh @@ -15,7 +15,8 @@ usage() echo "-e | --email :: notification email" echo "-l | --lock-all-tables" echo "-s | --single-transaction" - echo "-z | --compress :: gzip dump" + echo "-z | --gzip :: compress dump using gzip" + echo "-x | --xz :: compress dump using xz" echo "-m | --master :: set master data" echo "-q | --quiet :: silent mode" echo "-h | --help :: display this help" @@ -50,7 +51,9 @@ while [ "${1}" != "" ]; do -s | --single-transaction ) singletrans=1 ;; - -z | --compress ) compress=1 + -z | --gzip ) gzip=1 + ;; + -x | --xz ) xz=1 ;; -m | --master ) master=1 -q | --quiet ) quiet=1 @@ -105,6 +108,7 @@ mysqlparams=" --all-databases \ --comments \ --quick \ --force \ + --ignore-table=mysql.proc --log-error=/var/log/mysqldump.log" ; if [ "${singletrans}" ] ; then @@ -142,17 +146,26 @@ dump_file_name="${dir}/${prefix}.${date}.sql" ; mysqldump ${mysqlparams} > ${dump_file_name} ; -if [ "${compress}" ] ; then +if [ "${gzip}" ] ; then if [ ! "${quiet}" ] ; then - echo "Compressing dump (`date +\"%H:%M:%S\"`)..." ; + echo "Compressing dump by gzip (`date +\"%H:%M:%S\"`)..." ; fi gzip ${dump_file_name} ; +else + if [ "${xz}" ] ; than + + if [ ! "${quiet}" ] ; then + echo "Compressing dump by xz (`date +\"%H:%M:%S\"`)..." ; + fi + + xz ${dump_file_name} ; + fi fi if [ ! "${quiet}" ] ; then - echo "atabase dump completed (`date +\"%H:%M:%S\"`)..." ; + echo "Dump completed (`date +\"%H:%M:%S\"`)..." ; fi rm -f ${mypidfile} ;