Find the answer to your Linux question:
Results 1 to 3 of 3
if I run mysqldump from crontab and error occurs, I would like to have email send to me (reporting that backup is not working). Can this be done ?...
  1. #1
    Just Joined!
    Join Date
    Jan 2010
    Posts
    11

    crontab mysqldump err mail

    if I run mysqldump from crontab and error occurs, I would like to have email send to me (reporting that backup is not working).

    Can this be done ?

  2. #2
    Just Joined!
    Join Date
    Jan 2010
    Posts
    4
    Should be doable. Something similar to the following should work ( not tested ):

    Code:
    mysqldump --opt --user=mysqluser --password=secretpass dbname > dbname.sql || echo "mysqldump failure message" | mail -s 'mysqldump error' user@domain.com
    Basically, the stuff after the '||' is only executed if the command before it returns a non zero exit code. A successful mysqldump should return 0 and therefore no email would be sent.

    Hope this helps.

  3. #3
    Just Joined!
    Join Date
    Jan 2010
    Posts
    11
    Thanks a lot, tested it and it works.

    Didn't notice for a month that there are no 'usable' backups on
    production server. By pure luck spoted that mysqldump generated files
    were way to small.

    No such problem in the future.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...