From de2eb9ba3726128c9aef5983995c779e82e1177e Mon Sep 17 00:00:00 2001 From: Peter Date: Wed, 2 May 2018 01:49:02 +0200 Subject: [PATCH] Small changes for MacOS Eliminate showstoppers on MacOS GNU: sed -r MacOS: sed -E GNU: du -hs --si MacOS: du -hs --- .gitignore | 1 + automysqlbackup | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/automysqlbackup b/automysqlbackup index 0ac2248..58c6b10 100755 --- a/automysqlbackup +++ b/automysqlbackup @@ -100,9 +100,18 @@ load_default_config() { CONFIG_encrypt_password='password0123' } +# OS dependent options (showstoppers on MacOS) + if [[ $OSTYPE == darwin* ]]; then + OS_sed_option='-E' + OS_du_extra_option='' + else + OS_sed_option='-r' + OS_du_extra_option='--si' + fi + mysql_commands() { VERSION=`mysql -V | grep -oE "[0-9]+\.[0-9]+\.[0-9]+"` - NODOT_VER=`echo $VERSION | sed -r 's/\.//g'` + NODOT_VER=`echo $VERSION | sed $OS_sed_option 's/\.//g'` if [ "${CONFIG_mysql_dump_encrypted_login}" = "yes" ]; then export MYSQLDUMP="mysqldump --login-path=$CONFIG_mysql_dump_login_path" export MYSQLSHOW="mysqlshow --login-path=$CONFIG_mysql_dump_login_path" @@ -1994,7 +2003,7 @@ method_backup () { # -> finished information echo "Total disk space used for backup storage..." echo "Size - Location" - echo `du -hs --si "${CONFIG_backup_dir}"` + echo `du -hs $OS_du_extra_option "${CONFIG_backup_dir}"` echo echo "======================================================================" # <- finished information