Hi Guys,
as part of my ambitious foray into shell programming I have made a cron.daily to do the backup of my mysql database.
Basically I am going to setup a scp or rsync of this process when I have the other server properly setup.
Until that time I want to have my cron.daily do
1) a mysqldump (secure if possible - at the moment I am putting the password in in clear text = bad)
2) a bzip2 of the sql backup
3) a mail to the admin group summarising the output of these commands.
What I have so far is embarasingly simple and simply a concatenation of the two commands I have been using for this task manually!
Code:
stardotstar@helios:~$ cat /etc/cron.daily/archeli_backup
#!/bin/bash
mysqldump -u stardotstar --password=********** archeli_mysql > /home/stardotstar/backups/archeli_mysql_daily.sql
bzip2 -f --small /home/stardotstar/backups/archeli_mysql_daily.sql
stardotstar@helios:~$
I need to know how to direct any output from these commands to a file that I include in the email. So I get an email that says something like:
"Hi admingroup,
The daily backup is complete.
The output generated was:
[any errors or output here]"
Ideally I would like the backup files generated with date and time and I understand that I can get mysqldump to do this for me which will take care of the naming conventions for when I do my scp for example.
I cannot work out yet how to send mail from cron. mail admgrp[at]blahblah.com.au -s "Daily Backup" directs me to enter the message body and then break out...
I'm sure there would be a way of getting mail to send to that address and include as the body a file that is the template like above and then any output from the commands.
Can some kind guru give me some help creating this please?
In the mean time I will continue to tinker and fool around amongst man pages and google referernces L
Will