added xz compress option

This commit is contained in:
Naum Soloveychik
2020-01-12 11:11:47 +03:00
parent 14680704fa
commit 83ee72706e
2 changed files with 21 additions and 6 deletions

View File

@@ -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**

View File

@@ -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} ;