-
Notifications
You must be signed in to change notification settings - Fork 29
Backup
Backing up a CRM install involves backing up both the database and the SITE_HOME directory. In fact, you may think about storing the database backups in the SITE_HOME directory. That way, there's only one directory to tarball.
Backing up and restoring a MySQL database is covered in the MySQL documentation. You can use mysqldump to create a backup.
mysqldump -p --opt crm > crm.sql
All the site-specific configuration, customization, and data files are now
store in the SITE_HOME directory. By default, this is set to /crm/data
,
but you can set this wherever you like.
Any backup just needs to preserve the contents of that directory. You can create a tarball of the directory with
tar czvf data.tar.gz data
If you put your automated database dumps into this directory, you have just a single directory to tarball.
CRM includes a shell script that automates a complete backup.
You will need to edit scripts/backup.sh
with the values for your installation.
You should read through it, making sure all the directories are where
you want them.
The backup script is written to create nightly tarballs using the date as the filename. To save hard drive space, it purges old snapshots. If you have a tape backup system in place, be sure to add this location to your dailies.
Most linux systems have a /etc/cron.daily
directory.
You should be able to just copy scripts/backup.sh
to /etc/cron.daily
and make it executable.
cp scripts/backup.sh /etc/cron.daily/crm
chmod +x /etc/cron.daily/crm
If you've got a tarball, you can uncompress it with
tar xzvf 2014-07-14.tar.gz
To restore it you just have to put the old files back into place in your installation.
Depending on your Apache setup, after restoring the media, you may need to adjust permissions on the newly-restored files before Apache will serve them again.
chown -R apache data
Assuming you're storing the database dump in the SITE_HOME, you'll need to extract the tarball first. However, once you've uncompressed your tarball, you can restore your database by dropping, recreating, then loading the database from the dump file You can use mysql to restore data from a dump.
drop database crm;
create database crm;
exit
mysql -p crm < crm.sql
If you're using the backup script to do automated nightly backups, you can restore one of the nightlies by uncompressing it, restoring the database, and putting the media back in place.