Alfresco

Alfresco Backup Script for Linux Instance

A number of Enterprises have trusted Alfresco Enterprise Content Management and Business Process Management since years. IT team of the enterprises or the Alfresco support vendor requires conducting certain operations during Alfresco support or Alfresco content migration activities.


One such operation is taking backup of Alfresco. In this blog, we have described the steps for the same.
 

alfresco content migratione


First of all, why and when you should backup Alfresco?  There are three such activities before which it is strongly recommended to have a backup of Alfresco production data:

  1. Deploying customization to the Alfresco production instance
  2. Alfresco server migration
  3. Alfresco version upgrade


Backup of Alfresco involves two things:

  1. Content (content stores)
  2. Database (metadata)


Here, we have prepared the Alfresco backup script (for Linux) - which can help you take a complete backup of Alfresco.


This script can also help you retain latest few backups (e.g. last 3 backups). This will help you especially when you are performing backup operations at regular intervals using cronjobs.

 #!/bin/bash

### Created by Tridhya Tech Ltd.- http//www.tridhyatech.com ###

### This script takes following arguments in sequence
### DBUSER: Postgresql databse user
### DBPASS: Postgresql database password
### DBPORT: Port on which your postgresql is running
### SOURCE: Alfresco home path - e.g. /opt/alfresco-community
### DESTINATION: Path to the directory where you want to store backup e.g /home/admin/backup

### e.g. sh alfresco-backup.sh alfresco admin 5432 /opt/alfresco-community /home/admin/backup

### *note - Destination folder must be present
###       - Default database host name is taken 'localhost', you have to change it accordingly

DBUSER=$1
DBPASS=$2
DBPORT=$3
SOURCE=$4
DESTINATION=$5

OUTPUT=$(${SOURCE}/alfresco.sh status postgresql)
POSTGRES_STATUS=`echo $OUTPUT`
CHECK="postgresql already running"
NOW=$(date +"%m-%d-%Y-%H-%M-%S")
FORMAT="%m-%d-%Y-%H-%M-%S"

if [ "$POSTGRES_STATUS" = "$CHECK" ]; then 
CONTENTSTORE=${SOURCE}/alf_data/ 
POSTGRESQL=${SOURCE}/postgresql/ 

echo [$(date +${FORMAT})]"Performing Database Backup" 
echo "--------------------------------------------\n" 

cd / 
cd $DESTINATION 
mkdir "$NOW" 
cd "$NOW" 
mkdir alf_data 
mkdir database 

cd $POSTGRESQL/bin 
PGPASSWORD=${DBPASS} ${POSTGRESQL}bin/pg_dump -h localhost -p ${DBPORT} -U ${DBUSER} > "${DESTINATION}/${NOW}/database/alfresco_db_dump" 
echo [$(date +${FORMAT})]"Performing ContentStore backup" 

echo "--------------------------------------------\n" 
cp -R ${CONTENTSTORE} "${DESTINATION}/$NOW" 
echo [$(date +${FORMAT})]"Backup Completed" 

echo "--------------------------------------------\n" 

#echo [$(date +${FORMAT})]"Deleting old backups" 
### Following two lines are meant to retain only last 5 backups at destination 
#cd ${DESTINATION} #ls -1tr | head -n -5 | xargs -d '\n' rm -rf -f -- 
#echo "--------------------------------------------\n" 

else 

echo [$(date +${FORMAT})]"Postgresql Database Server is not running, aborting alfresco backup" 

fi


Please note:

  • The script is meant for Alfresco with PostgreSQL database hosted on Linux servers.
  • We have not considered the backup of Alfresco Module Packages and alfresco-global.properties file in this script. However, you can take a backup of these files manually before you migrate to new Alfresco instance.

#CTA-1#
 

A Preparation Guide for Alfresco Certified Engineer Test Read more
Alfresco ECM Consultants

Alfresco

Alfresco ECM Consultants Unveil Secrets to Success

Mastering Alfresco Development: Essential Tips for Success in ECM Solutions" provides crucial insights and strategies for developers to excel in creating robust ECM solutions using the Alfresco platform. With essential tips and best practices, this resource is indispensable for both novice and experienced developers seeking to harness Alfresco's full potential for ECM projects.

A Preparation Guide for Alfresco Certified Engineer Test

Alfresco

A Preparation Guide for Alfresco Certified Engineer Test

This blog serves as a comprehensive preparation guide for individuals planning to take the Alfresco Certified Engineer test, offering valuable insights, resources, and tips to help them succeed in the certification exam.

Transform Your Business With Digital Enterprise Solutions

Contact us

Our Offices

INDIA AHMEDABAD, INDIA

401, One World West, Nr. Ambli T-Junction 200, S P Ring Road, Bopal, Ahmedabad, Gujarat 380058

UK
UK

Kemp House 160 City Road, London, United Kingdom EC1V 2NX

GERMANY GERMANY

Nürnberger Str. 46 90579 Langenzenn Deutschland

AUSTRALIA AUSTRALIA

Level 36 Riparian Plaza, 71 Eagle Street, Brisbane, QLD 4000

USA USA

4411 Suwanee Dam road, Bld. 300 Ste. 350 Suwanee GA, 30024

SOUTH AFRICA SOUTH AFRICA

Cube Work Space, 24 Hans Strijdom Avenue, Cape Town

UAE DUBAI, UAE

B 503 Sama Tower, Sheikh Zayed Road, United Arab Emirates