Not having much luck trying to find a automated backup script that not only backup the mysql database and web directory to a external mounted drive , i managed to find snippets of code off the net and put together one that also deletes files older than a specified amount of time .


Place the following in a file , use cron/crontab to automate. Make the folder in the root called Backups , inside this make a few folders called Database , Directorys and Script .

THEDATE=`date +%d%m%y%H%M`
#Backup the database of website
mysqldump -u ${THEDBUSER} -p${THEDBPW} ${THEDB} | gzip > /Backups/Database/dbbackup_${THEDB}_${THEDATE}.bak.gz
#Backup the Folder of website
tar -czf /Backups/Directorys/Directory_backup_website_${THEDATE}.tar /var/html/www/website
#Delete old files more tha 180 days old
find /Backups/Directorys/Di* -mtime +60 -exec rm {} \;
find /Backups/Database/db* -mtime +60 -exec rm {} \;