@@ -55,6 +55,8 @@ let "N_backup_local_nofiles=0x20"
5555# @info: Default configuration options.
5656# @deps: (none)
5757load_default_config () {
58+ CONFIG_mysql=" /usr/bin/mysql"
59+ CONFIG_mysql_dump=" /usr/bin/mysqldump"
5860 CONFIG_configfile=" /etc/automysqlbackup/automysqlbackup.conf"
5961 CONFIG_backup_dir=' /var/backup/db'
6062 CONFIG_multicore=' yes'
@@ -530,7 +532,7 @@ parse_configuration () {
530532 db=${i% .* }
531533 table=${i# " $db " .}
532534 r=' \*' ; [[ " $i " =~ $r ]] || { tmp[z++]=" $i " ; continue ; }
533- while read -r; do tmp[z++]=" ${db} .${REPLY} " ; done < <( mysql ${authentication} " ${mysql_opt[@]} " --batch --skip-column-names -e " select table_name from information_schema.tables where table_schema='${db} ' and table_name like '${table// \* /% } ';" )
535+ while read -r; do tmp[z++]=" ${db} .${REPLY} " ; done < <( ${CONFIG_mysql} ${authentication} " ${mysql_opt[@]} " --batch --skip-column-names -e " select table_name from information_schema.tables where table_schema='${db} ' and table_name like '${table// \* /% } ';" )
534536 done
535537 for l in " ${tmp[@]} " ; do echo " exclude $l " ; done
536538 CONFIG_table_exclude=(" ${tmp[@]} " )
@@ -587,28 +589,28 @@ fullschema () {
587589 if (( $CONFIG_dryrun )) ; then
588590 case " ${CONFIG_mysql_dump_compression} " in
589591 ' gzip' )
590- echo " dry-running: mysqldump ${authentication} ${opt_fullschema[@]} | gzip_compression > ${1}${suffix} " ;
592+ echo " dry-running: ${CONFIG_mysql_dump} ${authentication} ${opt_fullschema[@]} | gzip_compression > ${1}${suffix} " ;
591593 ;;
592594 ' bzip2' )
593- echo " dry-running: mysqldump ${authentication} ${opt_fullschema[@]} | bzip2_compression > ${1}${suffix} " ;
595+ echo " dry-running: ${CONFIG_mysql_dump} ${authentication} ${opt_fullschema[@]} | bzip2_compression > ${1}${suffix} " ;
594596 ;;
595597 * )
596- echo " dry-running: mysqldump ${authentication} ${opt_fullschema[@]} > ${1}${suffix} " ;
598+ echo " dry-running: ${CONFIG_mysql_dump} ${authentication} ${opt_fullschema[@]} > ${1}${suffix} " ;
597599 ;;
598600 esac
599601 return 0;
600602 else
601603 case " ${CONFIG_mysql_dump_compression} " in
602604 ' gzip' )
603- mysqldump ${authentication} " ${opt_fullschema[@]} " | gzip_compression > " ${1}${suffix} " ;
605+ ${CONFIG_mysql_dump} ${authentication} " ${opt_fullschema[@]} " | gzip_compression > " ${1}${suffix} " ;
604606 return $?
605607 ;;
606608 ' bzip2' )
607- mysqldump ${authentication} " ${opt_fullschema[@]} " | bzip2_compression > " ${1}${suffix} " ;
609+ ${CONFIG_mysql_dump} ${authentication} " ${opt_fullschema[@]} " | bzip2_compression > " ${1}${suffix} " ;
608610 return $?
609611 ;;
610612 * )
611- mysqldump ${authentication} " ${opt_fullschema[@]} " > " ${1}${suffix} " ;
613+ ${CONFIG_mysql_dump} ${authentication} " ${opt_fullschema[@]} " > " ${1}${suffix} " ;
612614 return $?
613615 ;;
614616 esac
@@ -726,13 +728,13 @@ process_dbs() {
726728 uid=" ${uid:- 8: 8} "
727729 case " ${CONFIG_mysql_dump_compression} " in
728730 ' gzip' )
729- mysqldump ${authentication} " ${opt[@]} " " $@ " | gzip_compression > " $cfname " ;
731+ ${CONFIG_mysql_dump} ${authentication} " ${opt[@]} " " $@ " | gzip_compression > " $cfname " ;
730732 ;;
731733 ' bzip2' )
732- mysqldump ${authentication} " ${opt[@]} " " $@ " | bzip2_compression > " $cfname " ;
734+ ${CONFIG_mysql_dump} ${authentication} " ${opt[@]} " " $@ " | bzip2_compression > " $cfname " ;
733735 ;;
734736 * )
735- mysqldump ${authentication} " ${opt[@]} " " $@ " > " $cfname " ;
737+ ${CONFIG_mysql_dump} ${authentication} " ${opt[@]} " " $@ " > " $cfname " ;
736738 ;;
737739 esac
738740 add_manifest_entry " $manifest_file " " $cfname " " $pid " " $db " && parse_manifest " $manifest_file " && cp -al " $cfname " " ${CONFIG_backup_dir} " /latest/ && echo " Generated master backup $cfname " && return 0 || return 1
@@ -745,29 +747,29 @@ process_dbs() {
745747 case " ${CONFIG_mysql_dump_compression} " in
746748 ' gzip' )
747749 if (( $filename_flags & $filename_flag_gz )) ; then
748- diff <( gzip_compression -dc " ${manifest_latest_master_entry[0]} " ) <( mysqldump ${authentication} " ${opt[@]} " " $@ " ) | gzip_compression > " $cfname " ;
750+ diff <( gzip_compression -dc " ${manifest_latest_master_entry[0]} " ) <( ${CONFIG_mysql_dump} ${authentication} " ${opt[@]} " " $@ " ) | gzip_compression > " $cfname " ;
749751 elif (( $filename_flags & $filename_flag_bz2 )) ; then
750- diff <( bzip2_compression -dc " ${manifest_latest_master_entry[0]} " ) <( mysqldump ${authentication} " ${opt[@]} " " $@ " ) | gzip_compression > " $cfname " ;
752+ diff <( bzip2_compression -dc " ${manifest_latest_master_entry[0]} " ) <( ${CONFIG_mysql_dump} ${authentication} " ${opt[@]} " " $@ " ) | gzip_compression > " $cfname " ;
751753 else
752- diff " ${manifest_latest_master_entry[0]} " <( mysqldump ${authentication} " ${opt[@]} " " $@ " ) | gzip_compression > " $cfname " ;
754+ diff " ${manifest_latest_master_entry[0]} " <( ${CONFIG_mysql_dump} ${authentication} " ${opt[@]} " " $@ " ) | gzip_compression > " $cfname " ;
753755 fi
754756 ;;
755757 ' bzip2' )
756758 if (( $filename_flags & $filename_flag_gz )) ; then
757- diff <( gzip_compression -dc " ${manifest_latest_master_entry[0]} " ) <( mysqldump ${authentication} " ${opt[@]} " " $@ " ) | bzip2_compression > " $cfname " ;
759+ diff <( gzip_compression -dc " ${manifest_latest_master_entry[0]} " ) <( ${CONFIG_mysql_dump} ${authentication} " ${opt[@]} " " $@ " ) | bzip2_compression > " $cfname " ;
758760 elif (( $filename_flags & $filename_flag_bz2 )) ; then
759- diff <( bzip2_compression -dc " ${manifest_latest_master_entry[0]} " ) <( mysqldump ${authentication} " ${opt[@]} " " $@ " ) | bzip2_compression > " $cfname " ;
761+ diff <( bzip2_compression -dc " ${manifest_latest_master_entry[0]} " ) <( ${CONFIG_mysql_dump} ${authentication} " ${opt[@]} " " $@ " ) | bzip2_compression > " $cfname " ;
760762 else
761- diff " ${manifest_latest_master_entry[0]} " <( mysqldump ${authentication} " ${opt[@]} " " $@ " ) | bzip2_compression > " $cfname " ;
763+ diff " ${manifest_latest_master_entry[0]} " <( ${CONFIG_mysql_dump} ${authentication} " ${opt[@]} " " $@ " ) | bzip2_compression > " $cfname " ;
762764 fi
763765 ;;
764766 * )
765767 if (( $filename_flags & $filename_flag_gz )) ; then
766- diff <( gzip_compression -dc " ${manifest_latest_master_entry[0]} " ) <( mysqldump ${authentication} " ${opt[@]} " " $@ " ) > " $cfname " ;
768+ diff <( gzip_compression -dc " ${manifest_latest_master_entry[0]} " ) <( ${CONFIG_mysql_dump} ${authentication} " ${opt[@]} " " $@ " ) > " $cfname " ;
767769 elif (( $filename_flags & $filename_flag_bz2 )) ; then
768- diff <( bzip2_compression -dc " ${manifest_latest_master_entry[0]} " ) <( mysqldump ${authentication} " ${opt[@]} " " $@ " ) > " $cfname " ;
770+ diff <( bzip2_compression -dc " ${manifest_latest_master_entry[0]} " ) <( ${CONFIG_mysql_dump} ${authentication} " ${opt[@]} " " $@ " ) > " $cfname " ;
769771 else
770- diff " ${manifest_latest_master_entry[0]} " <( mysqldump ${authentication} " ${opt[@]} " " $@ " ) > " $cfname " ;
772+ diff " ${manifest_latest_master_entry[0]} " <( ${CONFIG_mysql_dump} ${authentication} " ${opt[@]} " " $@ " ) > " $cfname " ;
771773 fi
772774 ;;
773775 esac
@@ -781,28 +783,28 @@ process_dbs() {
781783 if (( $CONFIG_dryrun )) ; then
782784 case " ${CONFIG_mysql_dump_compression} " in
783785 ' gzip' )
784- echo " dry-running: mysqldump ${authentication} ${opt[@]} $@ | gzip_compression > ${cfname} "
786+ echo " dry-running: ${CONFIG_mysql_dump} ${authentication} ${opt[@]} $@ | gzip_compression > ${cfname} "
785787 ;;
786788 ' bzip2' )
787- echo " dry-running: mysqldump ${authentication} ${opt[@]} $@ | bzip2_compression > ${cfname} "
789+ echo " dry-running: ${CONFIG_mysql_dump} ${authentication} ${opt[@]} $@ | bzip2_compression > ${cfname} "
788790 ;;
789791 * )
790- echo " dry-running: mysqldump ${authentication} ${opt[@]} $@ > ${cfname} "
792+ echo " dry-running: ${CONFIG_mysql_dump} ${authentication} ${opt[@]} $@ > ${cfname} "
791793 ;;
792794 esac
793795 return 0;
794796 else
795797 case " ${CONFIG_mysql_dump_compression} " in
796798 ' gzip' )
797- mysqldump ${authentication} " ${opt[@]} " " $@ " | gzip_compression > " ${cfname} "
799+ ${CONFIG_mysql_dump} ${authentication} " ${opt[@]} " " $@ " | gzip_compression > " ${cfname} "
798800 ret=$?
799801 ;;
800802 ' bzip2' )
801- mysqldump ${authentication} " ${opt[@]} " " $@ " | bzip2_compression > " ${cfname} "
803+ ${CONFIG_mysql_dump} ${authentication} " ${opt[@]} " " $@ " | bzip2_compression > " ${cfname} "
802804 ret=$?
803805 ;;
804806 * )
805- mysqldump ${authentication} " ${opt[@]} " " $@ " > " ${cfname} "
807+ ${CONFIG_mysql_dump} ${authentication} " ${opt[@]} " " $@ " > " ${cfname} "
806808 ret=$?
807809 ;;
808810 esac
@@ -1073,13 +1075,13 @@ check_dependencies () {
10731075#
10741076parse_databases () {
10751077 # bash 4.x version
1076- # mapfile -t alldbnames < <(mysql ${authentication} --batch --skip-column-names -e "show databases")
1078+ # mapfile -t alldbnames < <(${CONFIG_mysql} ${authentication} --batch --skip-column-names -e "show databases")
10771079 alldbnames=()
10781080
10791081 printf " # Parsing databases ... "
10801082 # bash 3.0
10811083 local i; i=0;
1082- while read -r; do alldbnames[i++]=" $REPLY " ; done < <( mysql ${authentication} " ${mysql_opt[@]} " --batch --skip-column-names -e " show databases" )
1084+ while read -r; do alldbnames[i++]=" $REPLY " ; done < <( ${CONFIG_mysql} ${authentication} " ${mysql_opt[@]} " --batch --skip-column-names -e " show databases" )
10831085 unset i
10841086
10851087 # mkfifo foo || exit; trap 'rm -f foo' EXIT
@@ -2268,4 +2270,4 @@ elif (( $# == 0 )) && (( ${#opt_flags[@]} == 0 )); then
22682270 method_backup
22692271fi
22702272
2271- # END __main
2273+ # END __main
0 commit comments