I have a cron job running that calls a shell script. This sh file backs up the database and saves it to a folder on the server. That's working.
I know that at the time of generating the backup and / or save an error may occur. I would like to send this error to an email or generate some error log, something like that. Does anyone know how to do this?
Follow the script:
#!/bin/bash
# bkpDBData.sh
#
# gera um dump da base de dados, somente dos dados para um zip no servidor
#
# echo 'Iniciando backup SGI!';
local_save_backup=/local/salvar/backups
ano='date +%Y'
path_complete=$local_save_backup'/'$ano
# verifica se existe a pasta do local_save_backup+ano
# se nao existe, entao cria a pasta
if [ ! -d $path_complete ]; then
# echo "criar pasta";
mkdir $path_complete
# echo "pasta criada";
fi
mysqldump -h localhost -u user -psenha -x -e -t nome_da_base | gzip > $path_complete/'date +%Y%m%d_%H%M'_mysql.gz;
# echo 'Fim do backup SGI!';