Backup script to email

#1
I have a very simple backup script I use that is running via cron every week.

Is there a way I have have the script email me if the backup was successfull or if it failed?
 
#2
I have a very simple backup script I use that is running via cron every week.

Is there a way I have have the script email me if the backup was successfull or if it failed?
I used my control panel (DirectAdmin) to set up my backups weekly to a FTP server in my home. It automatically emails me when the backup is complete and if it was successful.

What control panel are you using if any?

I'm sure that you can do it though...
 
#3
I have cPanel.

cPanel will email me whent he script runs, But I dont think it will let me know if there is an error.

This is why I want the script to see if there was an error, if an error email eorr message, If ok, then email me the backup is ready.
 
#4
If you want the script to email you then you'll have to either add that code to said script or ask its developer to include this functionality.
 
#5
Here's the thing.

The code is very small.
I don't remember where I picked it up from.
Heres' what I have.
Code:
#!/bin/bash

# modify the following to suit your environment
export DB_BACKUP="/home/xxxx/backup"
export DB_USER="xxxx"
export DB_PASSWD="xxxxx"

# title and version
echo ""
echo "mySQL_backup"
echo "----------------------"
echo "* Rotating backups..."
rm -rf $DB_BACKUP/04
mv $DB_BACKUP/03 $DB_BACKUP/04
mv $DB_BACKUP/02 $DB_BACKUP/03
mv $DB_BACKUP/01 $DB_BACKUP/02
mkdir $DB_BACKUP/01

echo "* Creating new backup..."
mysqldump --user=$DB_USER --password=$DB_PASSWD --all-databases | bzip2 > $DB_BACKUP/01/mysql-`date +%Y-%m-%d`.sql.bz2
echo "----------------------"
echo "Done"
exit 0
I dont know what the coding would be to email. I dont want the actual archive emailed, just a notice that it was attempted, and if it was or not.
 
#6
I don't use cPanel, so I can't say for sure....

...but isn't there some type of integrated backup within the control panel that you could use instead of the script?
 
#8
That script doesn't include any error handling whatsoever, so it would pretty much have to be rewritten if you want it to tell you whether it was successful or not. Right now it doesn't know (or care) what happens.
 
Top