From 7c9f3f4d7320b9268d221bfd482bb0e0f784e3a7 Mon Sep 17 00:00:00 2001 From: deajan Date: Sun, 21 Dec 2014 22:28:05 +0100 Subject: [PATCH] Improved mysql dry backup and corrected mysql compress ratio --- CHANGELOG.md | 3 +++ obackup.sh | 17 ++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7346fe5..e2392ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,11 +16,14 @@ UNDER WORK - Commands like cp should have their stderr redirected to log file - Mysqldump must be checked for not telling success if a table is damaged (also check for event table error) +- Mysqldump commands error msg must be logged CHANGELOG --------- +- Fixed ignoring compression level in conf file +- Fixed dry mode sql backup output - Prevented triggering TrapError if there are no child processes to terminate on TrapQuit - Improved mysql debug logs - Prevent creation of backup-id less log file when DEBUG is set diff --git a/obackup.sh b/obackup.sh index 2d48b82..7b88199 100755 --- a/obackup.sh +++ b/obackup.sh @@ -5,7 +5,7 @@ AUTHOR="(L) 2013-2014 by Orsiris \"Ozy\" de Jong" CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr" PROGRAM_VERSION=1.84RC4 -PROGRAM_BUILD=2811201403 +PROGRAM_BUILD=2112201402 ## type doesn't work on platforms other than linux (bash). If if doesn't work, always assume output is not a zero exitcode if ! type -p "$BASH" > /dev/null @@ -791,7 +791,7 @@ function BackupDatabase LogError "Connectivity test failed. Stopping current task." exit 1 fi - dry_sql_cmd="$SSH_CMD mysqldump -u $SQL_USER --skip-lock-tables --single-transaction --database $1 > /dev/null 2>&1" + dry_sql_cmd="$SSH_CMD mysqldump -u $SQL_USER --skip-lock-tables --single-transaction --database $1 2>&1 > /dev/null" sql_cmd="$SSH_CMD mysqldump -u $SQL_USER --skip-lock-tables --single-transaction --database $1 $COMPRESSION_PROGRAM $COMPRESSION_OPTIONS > $LOCAL_SQL_STORAGE/$1.sql$COMPRESSION_EXTENSION" elif [ "$REMOTE_BACKUP" == "yes" ] && [ "$COMPRESSION_REMOTE" == "yes" ] then @@ -801,19 +801,19 @@ function BackupDatabase LogError "Connectivity test failed. Stopping current task." exit 1 fi - dry_sql_cmd="$SSH_CMD \"mysqldump -u $SQL_USER --skip-lock-tables --single-transaction --database $1 $COMPRESSION_PROGRAM $COMPRESSION_OPTIONS\" > /dev/null 2>&1" + dry_sql_cmd="$SSH_CMD \"mysqldump -u $SQL_USER --skip-lock-tables --single-transaction --database $1 $COMPRESSION_PROGRAM $COMPRESSION_OPTIONS\" 2>&1 > /dev/null" sql_cmd="$SSH_CMD \"mysqldump -u $SQL_USER --skip-lock-tables --single-transaction --database $1 $COMPRESSION_PROGRAM $COMPRESSION_OPTIONS\" > $LOCAL_SQL_STORAGE/$1.sql$COMPRESSION_EXTENSION" else - dry_sql_cmd="mysqldump -u $SQL_USER --skip-lock-tables --single-transaction --database $1 $COMPRESSION_PROGRAM $COMPRESSION_OPTIONS > /dev/null 2>&1" + dry_sql_cmd="mysqldump -u $SQL_USER --skip-lock-tables --single-transaction --database $1 $COMPRESSION_PROGRAM $COMPRESSION_OPTIONS 2>&1 > /dev/null" sql_cmd="mysqldump -u $SQL_USER --skip-lock-tables --single-transaction --database $1 $COMPRESSION_PROGRAM $COMPRESSION_OPTIONS > $LOCAL_SQL_STORAGE/$1.sql$COMPRESSION_EXTENSION" fi - LogDebug "SQL_CMD: $sql_cmd" - if [ $dryrun -ne 1 ] then + LogDebug "SQL_CMD: $sql_cmd" eval "$sql_cmd 2>&1" else + LogDebug "SQL_CMD: $dry_sql_cmd" eval "$dry_sql_cmd" fi exit $? @@ -1289,7 +1289,10 @@ function Init RSYNC_ARGS=$RSYNC_ARGS" --force" ## Set compression executable and extension - COMPRESSION_LEVEL=9 + if [ "$COMPRESSION_LEVEL" == "" ] + then + COMPRESSION_LEVEL=9 + fi if type -p xz > /dev/null 2>&1 then COMPRESSION_PROGRAM="| xz -$COMPRESSION_LEVEL"