Is it possible to have the bash script, that is executed using a cron job, posted below email the DB backup to me as well as saving a copy to the server as it is currently doing?
# Script Function:
# This bash script backups up the "DBname" and "DBname" db everyday at 4am with a file name time stamp and tar.gz zips the file.
# The "DBname" db will be saved in /backups/database_backups/"DBname"/
# The "DBname" db will be stored in /backups/database_backups/"DBname"/
# Db backups older than 30 days will be deleted.
#[Changes Directory]
cd /home/"accountname"/backups/
#[Old DB Deletion Script]
find /home/"accountname"/backups/database_backups -name "*.tar.gz" -mtime +30 -exec rm -f {} \;
#[Stamps the file name with a date]
TIMESTAMP=`date +%m-%d-%y-%H%M`
#[DB Backup Scripts]
# "DBname"
HOST=localhost
DBNAME="DBname"
USER="DBusername"
PASSWORD="DBpassword"
DUMP_PATH=/home/"accountname"/backups/database_backups/"DBname"
mysqldump --opt -c -e -Q -h$HOST -u$USER -p$PASSWORD $DBNAME > $DBNAME.sql
tar czpf $DUMP_PATH/$DBNAME.$TIMESTAMP.tar.gz $DBNAME.sql
rm -f $DBNAME.sql
# "DBname"
HOST=localhost
DBNAME="DBname"
USER="DBusername"
PASSWORD="DBpassword"
DUMP_PATH=/home/"accountname"/backups/database_backups/"DBname"
mysqldump --opt -c -e -Q -h$HOST -u$USER -p$PASSWORD $DBNAME > $DBNAME.sql
tar czpf $DUMP_PATH/$DBNAME.$TIMESTAMP.tar.gz $DBNAME.sql
rm -f $DBNAME.sql



LinkBack URL
About LinkBacks
Reply With Quote




