[root@vm mysql]# cat /home/gus/joomla_backup.sh
#!/bin/bash
#this script is in: /home/gus
#backup is in: /dms_full_backup
sysdate=`date ‘+%Y-%b-%d-%H:%M’`
echo “This is the SYSDATE:” $sysdate
#set the folder name of Joomla to be taken as backup:
prefix=”dms”
#backup Joomla file system:
#————————–
echo “Archive site dir…”
tar -zcvf /dms_full_backup/site/${prefix}_$(date +%Y-%b-%d-%H:%M).tar.gz /var/www/$prefix
#backup Joomla database:
#———————–
MUSER=”DB_USER”
MPASS=”DB_PASS”
mysqldump -u $MUSER -p$MPASS –databases dms25 –single-transaction | gzip -9 > /dms_full_backup/mysql/${prefix}_$(date +%Y-%b-%d-%H:%M).sql.gz
#delete old mysql backups (keep always the 10 most recent files)
cd /dms_full_backup/mysql
ls -A1t | tail -n +11 | xargs rm -rf
#delete old site backups (keep always the 10 most recent files)
cd /dms_full_backup/site
ls -A1t | tail -n +11 | xargs rm -rf
echo “Full Backup Done @” $sysdate
[root@vm mysql]# crontab -l
###START AT 1:30 AM EVERY DAY
30 1 * * * /home/gus/joomla_backup.sh
#*/1 * * * * /home/gus/joomla_backup.sh #EVERY MIN
[root@vm mysql]# date
Fri Jul 10 05:24:31 AZST 2015