A small guide to CMSMS Backup

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
User avatar
blast2007
Power Poster
Power Poster
Posts: 508
Joined: Wed Aug 01, 2007 5:36 pm

A small guide to CMSMS Backup

Post by blast2007 »

Following various thread related to CMSMS backup, here my little contribution.

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
/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
}
Then add this line to crontab (crontab -e)
0 21 * * * /etc/scripts/backup.sh > /dev/null 2>&1
Every night this script will run and will produce backups set  in /var/backups/web. The number of old backup is 30 (one month).

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
Pierre M.

Re: A small guide to CMSMS Backup

Post by Pierre M. »

Thank you for sharing this.

Please use the wiki to publish tips, howto and other docs and use the (documentation) forum to annonce these new wiki contributions.

Everybody can contribute to the wiki and improve it with his/her forum account. Both writing and reviewing, both content and layout. Thanks in advance.

Pierre M.
Post Reply

Return to “CMSMS Core”