Reputation: 3890
I get minified(without empty lines and format) text in email body when i cat the text from the file. But the file has well formatted text, is there a way i can preserve the format of text file when sending email without changing my code a lot especially with the arguments.
innobackupex-runner.sh: MySQL backup script
started: Tue Apr 7 20:00:01 PDT 2015
Check completed OK
New incremental backup
failed:
---------- ERROR OUTPUT from ----------
InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona LLC and/or its affiliates 2009-2013. All Rights Reserved.
This software is published under
the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.
Get the latest version of Percona XtraBackup, documentation, and help resources:
http://www.percona.com/xb/p
150407 20:00:04 innobackupex: Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup' as 'dbbackup' (using password: YES).
150407 20:00:04 innobackupex: Connected to MySQL server
150407 20:00:04 innobackupex: Executing a version check against the server...
150407 20:00:04 innobackupex: Done.
150407 20:00:04 innobackupex: Starting the backup operation
IMPORTANT: Please check that the backup run completes successfully.
At the end of a successful backup run innobackupex
prints "completed OK!".
innobackupex: Using server version 10.0.17-MariaDB-wsrep
innobackupex: Created backup directory /backups/xtrabackup/incr/2015-04-07_10-00-01/2015-04-07_20-00-04
150407 20:00:04 innobackupex: Starting ibbackup with command: xtrabackup --defaults-group="mysqld" --backup --suspend-at-end --target-dir=/backups/xtrabackup/incr/2015-04-07_10-00-01/2015-04-07_20-00-04 --innodb_data_file_path="ibdata1:12M:autoextend" --tmpdir=/tmp --tables='.*[.].*' --extra-lsndir='/tmp' --incremental-basedir='/backups/xtrabackup/incr/2015-04-07_10-00-01/2015-04-07_18-00-08'
innobackupex: Waiting for ibbackup (pid=4789) to suspend
innobackupex: Suspend file '/backups/xtrabackup/incr/2015-04-07_10-00-01/2015-04-07_20-00-04/xtrabackup_suspended_2'
xtrabackup: Error: cannot open /backups/xtrabackup/incr/2015-04-07_10-00-01/2015-04-07_18-00-08/xtrabackup_checkpoints
xtrabackup: error: failed to read metadata from /backups/xtrabackup/incr/2015-04-07_10-00-01/2015-04-07_18-00-08/xtrabackup_checkpoints
innobackupex: got a fatal error with the following stacktrace: at /usr/bin/innobackupex line 2704
main::wait_for_ibbackup_file_create('/backups/xtrabackup/incr/2015-04-07_10-00-01/2015-04-07_20-00...') called at /usr/bin/innobackupex line 2724
main::wait_for_ibbackup_suspend('/backups/xtrabackup/incr/2015-04-07_10-00-01/2015-04-07_20-00...') called at /usr/bin/innobackupex line 1977
main::backup() called at /usr/bin/innobackupex line 1601
innobackupex: Error: The xtrabackup child process has died at /usr/bin/innobackupex line 2704.
email toaddress
InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy and Percona LLC and/or its affiliates 2009-2013. All Rights Reserved. This software is published under the GNU GENERAL PUBLIC LICENSE Version 2, June 1991. Get the latest version of Percona XtraBackup, documentation, and help resources: http://www.percona.com/xb/p 150408 09:59:04 innobackupex: Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup' as 'dbbackup' (using password: YES). 150408 09:59:04 innobackupex: Connected to MySQL server 150408 09:59:04 innobackupex: Executing a version check against the server... 150408 09:59:04 innobackupex: Done. 150408 09:59:04 innobackupex: Starting the backup operation IMPORTANT: Please check that the backup run completes successfully. At the end of a successful backup run innobackupex prints "completed OK!". innobackupex: Using server version 10.0.17-MariaDB-wsrep innobackupex: Created backup directory /backups/xtrabackup/incr/2015-04-07_10-00-01/2015-04-08_09-59-04 150408 09:59:04 innobackupex: Starting ibbackup with command: xtrabackup --defaults-group="mysqld" --backup --suspend-at-end --target-dir=/backups/xtrabackup/incr/2015-04-07_10-00-01/2015-04-08_09-59-04 --innodb_data_file_path="ibdata1:12M:autoextend" --tmpdir=/tmp --tables='.*[.].*' --extra-lsndir='/tmp' --incremental-basedir='/backups/xtrabackup/incr/2015-04-07_10-00-01/2015-04-08_09-35-42' innobackupex: Waiting for ibbackup (pid=11728) to suspend innobackupex: Suspend file '/backups/xtrabackup/incr/2015-04-07_10-00-01/2015-04-08_09-59-04/xtrabackup_suspended_2' xtrabackup: Error: cannot open /backups/xtrabackup/incr/2015-04-07_10-00-01/2015-04-08_09-35-42/xtrabackup_checkpoints xtrabackup: error: failed to read metadata from /backups/xtrabackup/incr/2015-04-07_10-00-01/2015-04-08_09-35-42/xtrabackup_checkpoints innobackupex: got a fatal error with the following stacktrace: at /usr/bin/innobackupex line 2704 main::wait_for_ibbackup_file_create('/backups/xtrabackup/incr/2015-04-07_10-00-01/2015-04-08_09-59...') called at /usr/bin/innobackupex line 2724 main::wait_for_ibbackup_suspend('/backups/xtrabackup/incr/2015-04-07_10-00-01/2015-04-08_09-59...') called at /usr/bin/innobackupex line 1977 main::backup() called at /usr/bin/innobackupex line 1601 innobackupex: Error: The xtrabackup child process has died at /usr/bin/innobackupex line 2704.
send_notification "${SUBJECTPREFIX} Failed" "`cat $TMPFILE`" ${TOADDR}
send_notification()
{
HDR="`date +%m%d%y`"
unset ct
ct=$#
if [ $ct -lt 3 ]
then
echo "Please provide MSG text"
usage $0 :Notification Requires "[SUBJECT] [MSG] [TOADDR] ...(optional)..[RTNADDR] [CCADDR] "
return
else
subj=$1
msg=$2
toaddr=$3
rtnaddr=$4
ccaddr=$5
if [ $ct == 3 ]
then
echo "email toaddress"
echo $msg | mail -s $subj $toaddr
elif [ $ct == 4 ]
then
echo "email toaddress with return address"
echo $msg | mail -s $subj $toaddr -- -f $rtnaddr
elif [ $ct == 5 ]
then
echo "email toaddress and cc with return address"
# Now mail report out with a Return Address (not user thsat ran it)
# CC addresses and an TO
echo $msg | mail -s $subj -c $ccaddr $toaddr -- -f $rtnaddr
else
echo "In valid number of arguments"
fi
fi
}
Upvotes: 0
Views: 113
Reputation: 54583
If you change your script to pass the filename as the msg
parameter, and cat
the original file to the mail
program (rather than echo
), you will easily avoid the interpretation which discards the newlines.
That is, the minimal change you asked for would use this
cat $msg | mail -s $subj -c $ccaddr $toaddr -- -f $rtnaddr
Of course, someone will suggest that is a useless use of cat
, and note that you could rephrase it as
mail -s $subj -c $ccaddr $toaddr -- -f $rtnaddr < $msg
(which strays a little from minimal -- your choice).
Upvotes: 1