Print additional infos about errors to std_out.
This commit is contained in:
		| @@ -41,6 +41,12 @@ echononl(){ | ||||
|    fi | ||||
|    rm /tmp/shprompt$$ | ||||
| } | ||||
|  | ||||
| print_error_stdout() { | ||||
|    echo -e -n "\n   Host:  ${srcHost}\n   Error: $*" 1>&2 | ||||
|    echo "" | ||||
| } | ||||
|  | ||||
| # | ||||
| # | ||||
| fatal(){ | ||||
|   | ||||
| @@ -212,6 +212,7 @@ if $MIRROR ;then | ||||
|       if [ "$retval" = "24" ]; then | ||||
|          echolog "\t[ Notice ] \"$real_backupSrcDir\": \n\t`$cat $err_Log`\n" | ||||
|       else | ||||
|          print_error_stdout "Cannot mirror directory \"$real_backupSrcDir\"\n          $(cat "$err_Log")" | ||||
|          echolog "\t[ERROR] Cannot mirror directory \"$real_backupSrcDir\"  [ $duration ]\n\t`$cat $err_Log`\n" | ||||
|       fi | ||||
|    else | ||||
|   | ||||
| @@ -111,6 +111,7 @@ for _disk in $disks ; do | ||||
|       if [ "$retval" = "0" ]; then | ||||
|          echolog "\t--- \"info_${_disk}.txt\"  successfully saved ---" | ||||
|       else | ||||
|          print_error_stdout "Cannot save identification info for disk $disk:\n          $(cat $err_Log)" | ||||
|          echolog "\t[ERROR] Cannot save identification info for disk $disk: \n\t`$cat $err_Log`\n" | ||||
|       fi | ||||
|    fi | ||||
| @@ -158,6 +159,7 @@ for _disk in $disks ; do | ||||
|          if [ "$retval" = "0" ]; then | ||||
|             echolog "\t--- \"fdisk_${_disk}.txt\"  successfully saved ---" | ||||
|          else | ||||
|             print_error_stdout "Cannot save partition tables for $disk (info file):\n          $(cat $err_Log)" | ||||
|             echolog "\t[ERROR] Cannot save partition tables for $disk (info file): \n\t`$cat $err_Log`\n" | ||||
|          fi | ||||
|       fi | ||||
| @@ -185,6 +187,7 @@ for _disk in $disks ; do | ||||
|          if [ "$retval" = "0" ]; then | ||||
|             echolog "\t--- \"${_disk}.mbr\"  successfully saved ---" | ||||
|          else | ||||
|             print_error_stdout "Cannot save master boot record of disk $disk:\n          $(cat $err_Log)" | ||||
|             echolog "\t[ERROR] Cannot save master boot record of disk $disk: \n\t`$cat $err_Log`\n" | ||||
|          fi | ||||
|       else | ||||
| @@ -214,6 +217,7 @@ for _disk in $disks ; do | ||||
|          if [ "$retval" = "0" ]; then | ||||
|             echolog "\t--- \"${_disk}-partitions.sfdisk\"  successfully saved ---" | ||||
|          else | ||||
|             print_error_stdout "Cannot save partition table of disk $disk:\n          $(cat $err_Log)" | ||||
|             echolog "\t[ERROR] Cannot save partition table of disk $disk: \n\t`$cat $err_Log`\n" | ||||
|          fi | ||||
|       else | ||||
| @@ -252,6 +256,7 @@ for _disk in $disks ; do | ||||
|             if [ "$retval" = "0" ]; then | ||||
|                echolog "\t--- \"boot_sec-${_part}.bin\"  successfully saved ---" | ||||
|             else | ||||
|                print_error_stdout "Cannot save boot record of partition $partition:\n          $(cat $err_Log)" | ||||
|                echolog "\t[ERROR] Cannot save boot record of partition $partition: \n\t`$cat $err_Log`\n" | ||||
|             fi | ||||
|          else | ||||
| @@ -294,6 +299,7 @@ for _disk in $disks ; do | ||||
|          if [ "$retval" = "0" ]; then | ||||
|             echolog "\t--- \"fdisk_${_disk}.txt\"  successfully saved ---" | ||||
|          else | ||||
|             print_error_stdout "Cannot save partition tables for $disk (info file)\n          $(cat $err_Log)" | ||||
|             echolog "\t[ERROR] Cannot save partition tables for $disk (info file): \n\t`$cat $err_Log`\n" | ||||
|          fi | ||||
|       fi | ||||
| @@ -322,6 +328,7 @@ for _disk in $disks ; do | ||||
|          if [ "$retval" = "0" ]; then | ||||
|             echolog "\t--- \"${_disk}-partitions.sgdisk\"  successfully saved ---" | ||||
|          else | ||||
|             print_error_stdout "Cannot save partition table of disk $disk: \n          $(cat $err_Log)" | ||||
|             echolog "\t[ERROR] Cannot save partition table of disk $disk: \n\t`$cat $err_Log`\n" | ||||
|          fi | ||||
|       else | ||||
|   | ||||
| @@ -118,24 +118,56 @@ fi | ||||
| # ------------------ Ende Variable ------------------ # | ||||
| # --------------------------------------------------- # | ||||
|  | ||||
|     | ||||
| err_msg="Determin existing databases failed"  | ||||
| if [ $srcHost != "localhost" ] || $_via_ssh_tunnel ;then | ||||
|    if [ -n "$mysql_credential_args" ] ; then | ||||
|       DATABASES=`$ssh ${ssh_user}@$srcHost "$mysql $mysql_credential_args -N -s -e \"show databases\""` | ||||
|       MYSQL_VERSION=`$ssh ${ssh_user}@$srcHost "$mysql $mysql_credential_args -N -s -e \"SELECT VERSION()\""` | ||||
|       DATABASES="$($ssh ${ssh_user}@$srcHost "$mysql $mysql_credential_args -N -s -e \"show databases\"" 2> $err_Log)" | ||||
|       retval=$? | ||||
|    else | ||||
|       DATABASES=`$ssh ${ssh_user}@$srcHost "$mysql -u$mysql_user -p$mysql_password -N -s -e \"show databases\""` | ||||
|       MYSQL_VERSION=`$ssh ${ssh_user}@$srcHost "$mysql -u$mysql_user -p$mysql_password -N -s -e \"SELECT VERSION()\""` | ||||
|       DATABASES="$($ssh ${ssh_user}@$srcHost "$mysql -u$mysql_user -p$mysql_password -N -s -e \"show databases\"" 2> $err_Log)" | ||||
|       retval=$? | ||||
|    fi | ||||
| else | ||||
|    if [ -n "$mysql_credential_args" ] ; then | ||||
|       DATABASES=`$mysql $mysql_credential_args -N -s -e "show databases"` | ||||
|       MYSQL_VERSION=`$mysql $mysql_credential_args -N -s -e "SELECT VERSION()"` | ||||
|       DATABASES="$($mysql $mysql_credential_args -N -s -e "show databases" 2> $err_Log)" | ||||
|       retval=$? | ||||
|    else | ||||
|       DATABASES=`$mysql -u$mysql_user -p$mysql_password -N -s -e "show databases"` | ||||
|       MYSQL_VERSION=`$mysql -u$mysql_user -p$mysql_password -N -s -e "SELECT VERSION()"` | ||||
|       DATABASES="$($mysql -u$mysql_user -p$mysql_password -N -s -e "show databases" 2> $err_Log)" | ||||
|       retval=$? | ||||
|    fi | ||||
| fi | ||||
| if [ "$retval" != "0" ]; then | ||||
|    print_error_stdout "${err_msg}:\n          $(cat $err_Log)" | ||||
|    echolog "" | ||||
|    echolog "\t[ERROR] ${err_msg}\n\t        $(cat $err_Log)\n" | ||||
| fi | ||||
|  | ||||
| err_msg="Determine version information about MySQL/MariaDB failed."  | ||||
| if [ $srcHost != "localhost" ] || $_via_ssh_tunnel ;then | ||||
|    if [ -n "$mysql_credential_args" ] ; then | ||||
|       MYSQL_VERSION="$($ssh ${ssh_user}@$srcHost "$mysql $mysql_credential_args -N -s -e \"SELECT VERSION()\"" 2> $err_Log)" | ||||
|       retval=$? | ||||
|    else | ||||
|       MYSQL_VERSION=`$ssh ${ssh_user}@$srcHost "$mysql -u$mysql_user -p$mysql_password -N -s -e \"SELECT VERSION()\""` | ||||
|       retval=$? | ||||
|    fi | ||||
| else | ||||
|    if [ -n "$mysql_credential_args" ] ; then | ||||
|       MYSQL_VERSION="$($mysql $mysql_credential_args -N -s -e "SELECT VERSION()" 2> $err_Log)" | ||||
|       retval=$? | ||||
|    else | ||||
|       MYSQL_VERSION="$($mysql -u$mysql_user -p$mysql_password -N -s -e "SELECT VERSION()" 2> $err_Log)" | ||||
|       retval=$? | ||||
|    fi | ||||
| fi | ||||
| if [ "$retval" != "0" ]; then | ||||
|    print_error_stdout "${err_msg}:\n          $(cat $err_Log)" | ||||
|    echolog "" | ||||
|    echolog "\t[ERROR] ${err_msg}\n\t        $(cat $err_Log)\n" | ||||
| fi | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| MYSQL_VERSION_NUM=`echo $MYSQL_VERSION | awk -F \. '{ printf "%02d", $1; printf "%02d", $2; printf "%02d", $3 }'` | ||||
|  | ||||
| @@ -164,6 +196,7 @@ if $ARCHIVE ;then | ||||
|    ## ----------------------------- | ||||
|    ## - Backup SQL Grants for users | ||||
|    ## -  | ||||
|    found_errors=false | ||||
|    info_msg="save SQL Grants for users" | ||||
|    echononl "\t$info_msg" | ||||
|  | ||||
| @@ -244,6 +277,7 @@ if $ARCHIVE ;then | ||||
|    ## - look about errors.. | ||||
|    ## - | ||||
|    if [ "$retval" != "0" ]; then | ||||
|       print_error_stdout "${err_msg}:\n          $(cat $err_Log)" | ||||
|       echolog "" | ||||
|       echolog "\t[ERROR] ${err_msg}  [  $duration ]\n\t`$cat $err_Log`\n" | ||||
|       if ! $keep_backup_on_error ; then | ||||
| @@ -362,6 +396,7 @@ if $ARCHIVE ;then | ||||
| 			## - look about errors.. | ||||
| 			## - | ||||
| 			if [ "$retval" != "0" ]; then | ||||
|             print_error_stdout "${err_msg}:\n          $(cat $err_Log)" | ||||
| 				echolog "" | ||||
| 				echolog "\t[ERROR] ${err_msg}  [  $duration ]\n\t`$cat $err_Log`\n" | ||||
| 				if ! $keep_backup_on_error ; then | ||||
| @@ -472,6 +507,7 @@ if $ARCHIVE ;then | ||||
| 			## - look about errors.. | ||||
| 			## - | ||||
| 			if [ "$retval" != "0" ]; then | ||||
|             print_error_stdout "${err_msg}:\n          $(cat $err_Log)" | ||||
| 				echolog "" | ||||
| 				echolog "\t[ERROR] ${err_msg}  [  $duration ]\n\t`$cat $err_Log`\n" | ||||
| 				if ! $keep_backup_on_error ; then | ||||
| @@ -583,6 +619,7 @@ if $ARCHIVE ;then | ||||
|          ## - look about errors.. | ||||
|          ## - | ||||
|          if [ "$retval" != "0" ]; then | ||||
|             print_error_stdout "${err_msg}:\n          $(cat $err_Log)" | ||||
|             echolog "" | ||||
|             echolog "\t[ERROR] ${err_msg}  [  $duration ]\n\t`$cat $err_Log`\n" | ||||
|             if ! $keep_backup_on_error ; then | ||||
| @@ -696,6 +733,7 @@ if $ARCHIVE ;then | ||||
|       ## - look about errors.. | ||||
|       ## - | ||||
|       if [ "$retval" != "0" ]; then | ||||
|          print_error_stdout "${err_msg}:\n          $(cat $err_Log)" | ||||
|          echolog "" | ||||
|          echolog "\t[ERROR] ${err_msg}  [  $duration ]\n\t`$cat $err_Log`\n" | ||||
|          if ! $keep_backup_on_error ; then | ||||
| @@ -805,6 +843,7 @@ if $ARCHIVE ;then | ||||
|       ## - look about errors.. | ||||
|       ## - | ||||
|       if [ "$retval" != "0" ]; then | ||||
|          print_error_stdout "${err_msg}:\n          $(cat $err_Log)" | ||||
|          echolog "" | ||||
|          echolog "\t[ERROR] ${err_msg}  [  $duration ]\n\t`$cat $err_Log`\n" | ||||
|          if ! $keep_backup_on_error ; then | ||||
| @@ -900,6 +939,7 @@ if $ARCHIVE ;then | ||||
|    ## - look about errors.. | ||||
|    ## - | ||||
|    if [ "$retval" != "0" ]; then | ||||
|       print_error_stdout "${err_msg}:\n          $(cat $err_Log)" | ||||
|       echolog "" | ||||
|       echolog "\t[ERROR] ${err_msg}  [  $duration ]\n\t`$cat $err_Log`\n" | ||||
|       if ! $keep_backup_on_error ; then | ||||
| @@ -1047,6 +1087,7 @@ if $ARCHIVE ;then | ||||
|          ## - look about errors.. | ||||
|          ## - | ||||
|          if [ "$retval" != "0" ]; then | ||||
|             print_error_stdout "${err_msg}:\n          $(cat $err_Log)" | ||||
|             echolog "" | ||||
|             echolog "\t[ERROR] ${err_msg}  [  $duration ]\n\t`$cat $err_Log`\n" | ||||
|             if ! $keep_backup_on_error ; then | ||||
| @@ -1198,6 +1239,7 @@ if $ARCHIVE ;then | ||||
|       ## - look about errors.. | ||||
|       ## - | ||||
|       if [ "$retval" != "0" ]; then | ||||
|          print_error_stdout "${err_msg}:\n          $(cat $err_Log)" | ||||
|          echolog "" | ||||
|          echolog "\t[ERROR] ${err_msg}  [  $duration ]\n\t`$cat $err_Log`\n" | ||||
|          if ! $keep_backup_on_error ; then | ||||
|   | ||||
| @@ -19,6 +19,8 @@ | ||||
|     | ||||
| if $mount_netdir ; then | ||||
|    if [ $srcHost != "localhost" ] || $_via_ssh_tunnel ;then | ||||
|       print_error_stdout "Mounting network directories is only possible for localhost - yet:\n          $(cat $err_Log)" | ||||
|       echolog "" | ||||
|       echolog "\t[ERROR] Mounting network directories is only possible for localhost - yet" | ||||
|       exit 1 | ||||
|    else | ||||
| @@ -31,6 +33,8 @@ if $mount_netdir ; then | ||||
|       sleep 5 | ||||
|  | ||||
|       if ! df | grep "$backup_dir" > /dev/null 2>&1 ;then | ||||
|          print_error_stdout "Cannot mount network directory to \"$backup_dir\":\n          $(cat $err_Log)" | ||||
|          echolog "" | ||||
|          echolog "\t[ERROR] Cannot mount network directory to \"$backup_dir\"" | ||||
|          exit 1 | ||||
|       fi | ||||
| @@ -49,6 +53,8 @@ backup_dir=$backup_dir $script_dir/dir_backup.sh | ||||
|        | ||||
| if $mount_netdir ; then | ||||
|    if [ $srcHost != "localhost" ];then | ||||
|       print_error_stdout "Mounting network directories is only possible for localhost - yet:\n          $(cat $err_Log)" | ||||
|       echolog "" | ||||
|       echolog "\t[ERROR] Mounting network directories is only possible for localhost - yet" | ||||
|       exit 1 | ||||
|    else | ||||
|   | ||||
| @@ -54,11 +54,21 @@ if [ -z "$pg_dump" ]; then | ||||
|    pg_dump="/usr/local/pgsql/bin/pg_dump" | ||||
| fi | ||||
|  | ||||
| err_msg="Determin existing databases failed" | ||||
| if [ $srcHost != "localhost" ] || $_via_ssh_tunnel ;then | ||||
|    DATABASES=`$ssh ${ssh_user}@$srcHost "$sudo -u $pgsql_user $psql  -lt" \ | ||||
|       | $grep -v -e"^$" | $awk '{print$1}'`  | ||||
|  | ||||
|    DATABASES="$($ssh ${ssh_user}@$srcHost "$sudo -u $pgsql_user $psql  -lt" \ | ||||
|       | $grep -v -e"^$" | $awk '{print$1}' 2> /tmp/error)" | ||||
|    retval=$? | ||||
|  | ||||
| else | ||||
|    DATABASES=`$su - $pgsql_user -c "$psql  -lt" | $grep -v -e"^$" | $awk '{print$1}'` | ||||
|    DATABASES="$($su - $pgsql_user -c "$psql  -lt" | $grep -v -e"^$" | $awk '{print$1}' 2> /tmp/error)" | ||||
|    retval=$? | ||||
| fi | ||||
| if [ "$retval" != "0" ]; then | ||||
|    print_error_stdout "${err_msg}:\n          $(cat $err_Log)" | ||||
|    echolog "" | ||||
|    echolog "\t[ERROR] ${err_msg}\n\t        $(cat $err_Log)\n" | ||||
| fi | ||||
|  | ||||
|  | ||||
| @@ -131,6 +141,7 @@ if $ARCHIVE ;then | ||||
|    ## - look about errors.. | ||||
|    ## - | ||||
|    if [ "$retval" != "0" ]; then | ||||
|       print_error_stdout "${err_msg}:\n          $(cat $err_Log)" | ||||
|       echolog "" | ||||
|       echolog "\t[ERROR] ${err_msg}  [ $duration ]\n\t`$cat $err_Log`\n" | ||||
|       if ! $keep_backup_on_error ; then | ||||
| @@ -223,6 +234,7 @@ if $ARCHIVE ;then | ||||
|    ## - look about errors.. | ||||
|    ## - | ||||
|    if [ "$retval" != "0" ]; then | ||||
|       print_error_stdout "${err_msg}:\n          $(cat $err_Log)" | ||||
|       echolog "" | ||||
|       echolog "\t[ERROR] ${err_msg}  [ $duration ]\n\t`$cat $err_Log`\n" | ||||
|       if ! $keep_backup_on_error ; then | ||||
| @@ -324,6 +336,7 @@ if $ARCHIVE ;then | ||||
|       ## - look about errors.. | ||||
|       ## - | ||||
|       if [ "$retval" != "0" ]; then | ||||
|          print_error_stdout "${err_msg}:\n          $(cat $err_Log)" | ||||
|          echolog "" | ||||
|          echolog "\t[ERROR] ${err_msg}  [ $duration ]\n\t`$cat $err_Log`\n" | ||||
|          if ! $keep_backup_on_error ; then | ||||
|   | ||||
| @@ -57,11 +57,25 @@ fi | ||||
| # ------------------ Ende Variable ------------------ # | ||||
| # --------------------------------------------------- # | ||||
|  | ||||
| err_msg="Determin existing SVN repositories failed" | ||||
| if [ $srcHost != "localhost" ] || $_via_ssh_tunnel ;then | ||||
|    _REPOSITORIES=`ssh ${ssh_user}@$srcHost "$sudo $find $svn_source_base_path -maxdepth 1 -type d -exec basename 'realpath {}' \;"` | ||||
|    #_REPOSITORIES=`ssh ${ssh_user}@$srcHost "$sudo $find $svn_source_base_path -maxdepth 1 -type d -exec basename 'realpath {}' \;"` | ||||
|  | ||||
|    _REPOSITORIES="$(ssh ${ssh_user}@$srcHost "$sudo $find $svn_source_base_path -maxdepth 1 -type d -exec basename 'realpath {}' \;" 2> /tmp/error)" | ||||
|    retval=$? | ||||
|  | ||||
| else | ||||
|    _REPOSITORIES=`find $svn_source_base_path -maxdepth 1 -type d -exec basename 'realpath {}' \;` | ||||
|    #_REPOSITORIES=`find $svn_source_base_path -maxdepth 1 -type d -exec basename 'realpath {}' \;` | ||||
|  | ||||
|    _REPOSITORIES="$(find $svn_source_base_path -maxdepth 1 -type d -exec basename 'realpath {}' \; 2> /tmp/error)" | ||||
|    retval=$? | ||||
| fi | ||||
| if [ "$retval" != "0" ]; then | ||||
|    print_error_stdout "${err_msg}:\n          $(cat $err_Log)" | ||||
|    echolog "" | ||||
|    echolog "\t[ERROR] ${err_msg}\n\t        $(cat $err_Log)\n" | ||||
| fi | ||||
|  | ||||
|  | ||||
| for repos in $_REPOSITORIES ; do | ||||
|    _dir=`basename $svn_source_base_path` | ||||
| @@ -142,6 +156,7 @@ if $ARCHIVE ;then | ||||
|       ## - look about errors.. | ||||
|       ## - | ||||
|       if [ "$retval" != "0" ]; then | ||||
|          print_error_stdout "${err_msg}:\n          $(cat $err_Log)" | ||||
|          echolog "" | ||||
|          echolog "\t[ERROR] ${err_msg}  [ $duration ]\n\t`$cat $err_Log`\n" | ||||
|          if ! $keep_backup_on_error ; then | ||||
|   | ||||
		Reference in New Issue
	
	Block a user