cancel
Showing results for 
Search instead for 
Did you mean: 

how to get the data and metadata from Alfresco

amantay
Champ in-the-making
Champ in-the-making
Hi friends,
I need to move data from one server to another. With all the metadata and the database. How to do it?

thanks advance!
6 REPLIES 6

billerby
Champ on-the-rise
Champ on-the-rise
My approach would be to take a backup of the contentstore and the database, and then restore this onto the new server where you have installed a vanilla Alfresco.

/Erik

amantay
Champ in-the-making
Champ in-the-making
ok Eric, but no need to copy the folder  "alf_index", I thought it was a repository for the index of data, and it is also necessary?

billerby
Champ on-the-rise
Champ on-the-rise
You should follow a normal backup routine. That is for (offline backup):

1. Stop Alfresco
2. Backup the database (mysqldump if you are running mysql)
3. Backup the alf_data directory. (this one contains the contentstore and the indexes)
4. Start Alfresco

If you need to run an online backup you should exclude the lucene-indexes folder from the backup, otherwise you will end up with a corrupt contentstore. You will then need to reindex (from the point of time of the backup-lucene-indexes timestamps) by "setting index.recovery.mode=FULL"

Here is an example of a offline backup script I wrote for a windows environment:

http://blog.billerby.com/backup-of-alfresco-in-a-windows-environment

/Erik

amantay
Champ in-the-making
Champ in-the-making
I started working with Alfresco recently, and I fear that I not quite understand your explanation, could you please describe in detail all the action? My OS is Linux(Ubuntu), I'm using Alfresco-3.4.c with own mysql. Thanks..

billerby
Champ on-the-rise
Champ on-the-rise
amantay,

Okay, I'm pasting a linux - online backup script below that works for me on a 3.4.c community default installation. Make sure the environmnent variables in the beginning of the file are correct. Run the command and you will get a compressed file containing an sql-file and the alf_data directory. In the script there are restoration instructions, so you just have to move the file to your new machine, unzip, untar and replace the alf_data-dir of your new installation. Then import the sql-file as instructed.


#!/bin/bash
# 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;
#
# Author Erik Billerby, Acando

ALF_BASEDIR=/opt/alfresco
ALF_DATA_DIRNAME=alf_data
ALF_BACKUP_DIR=backup
MYSQL_HOME=/opt/alfresco/mysql
DB_USERNAME=alfresco
DB_PWD=alfresco
DB_NAME=alfresco
TODAY_STRING=`date +%Y%m%d-%H%M`;
MAX_AGE=10
BACKUP_DEL_CMD="rm {}"
echo "=== Starting hot backup of Alfresco ==="

# First stop Alfresco
# echo "=== Stopping Alfresco ==="
# $ALF_BASEDIR/alfresco.sh stop

# Navigate to the alf_data.dir
cd $ALF_BASEDIR/$ALF_DATA_DIRNAME

# Create a database dump and store it togheter with the data.
$MYSQL_HOME/bin/mysqldump -u$DB_USERNAME -p$DB_PWD $DB_NAME > $DB_NAME.sql
sleep 10;

cd $ALF_BASEDIR

# tar and gzip the data directory and move this to the backup folder,
# using a date extension in the name for easy identification
# Exclude the lucene indexes, since this is a hot backup procedure.
# Lucene indexes will be automatically rolled forward to a correct
# state by Alfresco from the backup-lucene-indexes folder.
# For this to happen the index.recovery.mode property must be set
# to AUTO (repository.properties OR alfresco-global.properties)
tar -cvzpP –file=$ALF_BACKUP_DIR/$TODAY_STRING.tar.gz –exclude='lucene-indexes' $ALF_DATA_DIRNAME

# delete the mysqldump file from the alf.data_dir
echo "Removing temporary mysql backup file $ALF_DATA_DIRNAME/$DB_NAME.sql"
rm -f $ALF_DATA_DIRNAME/$DB_NAME.sql

# Remove tar files older than number of days specified in $MAX_AGE
find $ALF_BACKUP_DIR -mindepth 1 -maxdepth 1 -name "*.tar.gz" -daystart -ctime +$MAX_AGE -exec $BACKUP_DEL_CMD \;

echo "=== Backup of Alfresco finished ==="
# Command to untar the backup file:
# tar -xvf filename.tar

# Copy the untared alf_data folder to ALF_BASEDIR:
# cp -R backup/alf_data .

# Command to restore the database (and yes it should be latin1
# even if the db and tables are set to utf8):
# mysql -u$DB_USERNAME -p$DB_PWD –default-character-set=latin1 $DB_NAME < $DB_NAME.sql

#echo "=== Starting Alfresco ==="


Good luck!
/Erik

amantay
Champ in-the-making
Champ in-the-making
Thank you very much Erik!,

Tip for the future, if you are a beginner :wink: . In this file (<alfresco_home>/tomcat/shared/classes/alfresco-global.properties) you have all information about your alfresco. And get information about the following PATH's from alfresco-global.properties

ALF_BASEDIR=/opt/alfresco  # this is my <alfresco_home>
ALF_DATA_DIRNAME=/opt/storage/alf_data
ALF_BACKUP_DIR=backup # create new folder in <alfresco_home>
MYSQL_HOME=/opt/alfresco/mysql
DB_USERNAME=alfresco
DB_PWD=alfresco
DB_NAME=alfresco

in my alfresco-global.properties:

dir.root=/opt/storage/alf_data

db.username=alfresco
db.password=alfresco
db.name=alfresco