Cold Backup for Alfresco
The script below was created as part of an Alfresco upgrade process and meant to be run manually. This is fairly trivial cold backup script for Alfresco 2.9b, which is a dead release tree from our friends at Alfresco. It hasn’t been tested with any other version and only backs up locally, but could easily backup remote with sshfs or nfs mounts or even rdiff-backup commands swapped in.
For nightly backup of our production servers, we actually perform rdiff-backups of shutdown virtual machines, which take about 3 minutes each. That little amount of downtime to have a differential backup of the entire VM is worth it to us.
#!/bin/sh # ############################################################### # This script should not be run from cron. It will wait for the mysql # DB password to be entered. # # Created by JDPFU 10/2009 # # ############################################################### # Alfresco Backup Script - tested with Alfresco v2.9b # Gets the following files # - alf_data/ # - Alfresco MySQL DB # - Alf - Extensions # - Alf - Global Settings # ############################################################### export TOP_DIR=/opt/Alfresco2.9b DB_NAME=alfresco_2010_8392 export EXT_DIR=$TOP_DIR/tomcat/shared/classes/alfresco/extension export BACK_DIR=/backup/ALFRESCO export BACKX_DIR=$BACK_DIR/extension # Shutdown Alfresco /etc/init.d/alfresco.sh stop # Backup the DB and important files. # dir.root setting will change in the next version /usr/bin/mkdir -p $BACK_DIR cd $BACK_DIR/; /usr/bin/rsync -vv -u -a --delete --recursive --stats --progress $TOP_DIR/alf_data $BACK_DIR/ echo " Reading root MySQL password from file " /usr/bin/mysqldump -u root \ -p`cat ~root/bin/$DB_NAME.passwd.root` $DB_NAME | \ /bin/gzip > $BACK_DIR/${DB_NAME}_`date +%Y%m%d`.gz /usr/bin/find $BACK_DIR -type f -name "$DB_NAME"/* -atime 60 -delete /usr/bin/cp $TOP_DIR/*sh $BACK_DIR /usr/bin/mkdir -p $BACKX_DIR /usr/bin/rsync -vv -u -a --delete --recursive --stats --progress $EXT_DIR/* $BACKX_DIR/ # Start Alfresco /etc/init.d/alfresco.sh start
Why a cold backup? Unless you have a really large DB, being down a few minutes isn’t really a big deal. If you can’t afford to be down, you would already be mirroring databases and automatically fail over anyway. Right?
We use a few extensions for Alfresco, that’s why we bother with the extensions/ directory.
There are many ways to make this script better. It was meant as a trivial example or starting point to show simple scripting methods while still being useful.
Trackbacks
Use the following link to trackback from your own site:
https://blog.jdpfu.com/trackbacks?article_id=389