Preface:
This solution is for owned server or for system where you can access to crontab, tar, gzip, mysqldump, etc. Please check if all this conditions are accomplished.
This solution create two backup files (one for db and one for filesystem) on the same CMSMS server, that should be saved on external media (tape, portable HDD, USB media, CDROM, DVDROM, ...).
All your CMSMS data are stored in database and in filesystem.
In database (typical mysql) you can find pages content, settings and so on, in file system you can find images, uploades files, ...
These istructions can be used to create one or more backup set, as you need moreover it use rotate log to have an hystorical sequence of backup so you can restore a specific snapshot.
I used these directories
backup directory: /var/backups/web
script directory: /etc/scripts
logrotate directory: /etc/logrotate.d/
but you can change according to your needs.
You need to create two files and crontab modification.
create /etc/scripts/backup.sh (give 700 permission to file)
#/bin/bash
logger -t BACKUP Starting www backup
logger -t BACKUP Logrotate
/usr/sbin/logrotate -f /etc/logrotate.d/backup_www
logger -t BACKUP MySQL dump
mysqldump -uyour_db_user -pyour_db_password --host=yourhost --opt --verbose --compatible=mysql40 --default-character-set=latin1 --all-databases | gzip -f -c > /var/backups/web/www_db_dump.sql.gz
logger -t BACKUP creating filesystem backup
tar -cpzvf /var/backups/web/www.tar.gz /var/www --exclude='./dir_to_exclude'
logger -t BACKUP Ending www backup
create file /etc/logrotate.d/backup_www
Then add this line to crontab (crontab -e)/var/backups/web/www.tar.gz {
rotate 30 #change this value if you want keep more or few daily backup set
daily
missingok
notifempty
}
/var/backups/web/www_db_dump.sql.gz{
rotate 30 #change this value if you want keep more or few daily backup set
daily
missingok
notifempty
}
Every night this script will run and will produce backups set in /var/backups/web. The number of old backup is 30 (one month).0 21 * * * /etc/scripts/backup.sh > /dev/null 2>&1
Restoring a backup set is very easy. Unzip filesystem tgz overwriting all files, then restore mysql dump as you prefer, via mysql console or via phpmyadmin.
Waiting for your opinion
Best regards
blast