I have been working with WCM & ECM for over 7 years. Designing and developing solutions for my customers. I have worked with customer of all sizes from large corporate and fortune 100 companies, to Federal Agencies, and smaller companies. This blog will be dedicated to helping others in the CMS industry find solutions that are sometimes outside the box. Having worked for a large ECM vendor for several years it has been nice to not be as restricted in the solutions that I provide.

About Me

Wednesday, February 21, 2007

Backups and Cross Platform Data?

Backups

In looking at possible backup solutions for Alfresco with MySql I found a post on the forum that mentioned the basics: http://forums.alfresco.com/viewtopic.php?t=2761&highlight=backup

I decided to take this post and carry things a little bit further. I wanted something that could not only backup Alfresco but do the restore.

The script below is executed with one of two commands:

alfresco_backup.sh -backup - This archives the alf_data directory; as well as, does an export from Mysql of the Alfresco database.

alfresco_backup.sh -restore - This restores the information by first moving the existing alf_data directory, and then replacing it with the archive contents. It also imports the Mysql Alfresco database.

Note: At this time the script does not drop, or create the alfresco database. It also does not set the permissions on the database. I wanted to wait until GA to finalize the script in case there were any changes.

Does anyone know on the restore is dropping the database is absolutely necessary? or is there a better way? Also is it possible to import only one webproject?

Importing into another Instance

The script is also able to backup Alfresco and restore it to another Alfresco instance. I copied the backup files to another server and ran the script with the restore options. This did import the content, and the alf_data into the other system. The active workflows were all in tact and things appeared to be good.

Cross Platform

I wanted to take this to the next level so manually I followed what the script did and was able to zip up the alf_data directory, and import the alfresco database into Mysql running on a Windows 2000 Server. All of the workflows and content appeared to be unharmed by the move in Operating systems.

I remember back to my days at Interwoven and when I was there it was possible to port the backing store between machines, but only if they were on the same operating system flavor and early on that was even difficult.

So very nice Alfresco!

My question now is will this porting from OS to OS be supported or are there issues that I could/should expect.

Script:

#!/bin/sh
# Start or stop Alfresco server
# Set the following to where Tomcat is installed
# Old Directory is moved with the time in miliseconds as the value

# Run this script with either "backup" or "restore" as the option.

# Script assumes that Alfresco Database exists and that the user alfresco
# has been granted appropriate permissions
# i.e.
# from mysql prompt: create database alfresco;
# grant all on alfresco.* to 'alfresco'@'localhost' identified by 'alfresco' with grant option;
# grant all on alfresco.* to 'alfresco'@'localhost.localdomain' identified by 'alfresco' with grant option;
#
# Thanks to the alfresco forum:http://forums.alfresco.com/viewtopic.php?t=2761&highlight=backup
# Questions: David Musser - dmusser@eyestreet.com
#
# NOTE: The script also assumes that alfresco is NOT running during the backup.
#
export ALF_DATA_BASE=/etc/opt/alfresco
export ALF_DATA_DIRNAME=alf_data
export BACKUP_DIR=/backup
export DB_USERNAME=alfresco
export DB_PWD=alfresco
export DB_NAME=alfresco

if [ "$1" = "backup" ]; then
cd $ALF_DATA_BASE/$ALF_DATA_DIRNAME
mysqldump -u$DB_USERNAME -p$DB_PWD $DB_NAME > $DB_NAME.sql
cd $ALF_DATA_BASE
tar cvfz $BACKUP_DIR/$ALF_DATA_DIRNAME.tgz $ALF_DATA_DIRNAME

elif [ "$1" = "restore" ]; then
cd $BACKUP_DIR
gzip -d alf_data.tgz
tar -xvf alf_data.tar

mv $ALF_DATA_BASE/$ALF_DATA_DIRNAME $ALF_DATA_BASE/$(date +%N)_$ALF_DATA_DIRNAME
mv $ALF_DATA_DIRNAME $ALF_DATA_BASE
cd $ALF_DATA_BASE/$ALF_DATA_DIRNAME

mysql -u$DB_USERNAME -p$DB_PWD $DB_NAME < $DB_NAME.sql

fi

Please test this on a server you do not care about! Do not get mad at me if the server explodes, and the sky falls etc... As I mentioned above comments are welcome!