Call Us India :- +91 9925144200       US :- +1 (732) 927-5544       Email us :


Jan 05

Alfresco Backup Script for Linux Instance

A number of Enterprises have trusted Alfresco for 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 a 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.


### Created by ContCentric IT Services Pvt. Ltd.- http// ###

### 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 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


OUTPUT=$(${SOURCE}/ status postgresql)
CHECK="postgresql already running"
NOW=$(date +"%m-%d-%Y-%H-%M-%S")

if [ "$POSTGRES_STATUS" = "$CHECK" ]; then 

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

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

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" 
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" 


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


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 file in this script. However, you can take a backup of these files manually before you migrate to new Alfresco instance.

Hope you find this blog useful. Please contact us if you want to know more from us. Special thanks to Francesco Corti and Jeff Potts for suggesting improvements in the code.

Kintu Barot

About The Author

Kintu is an Alfresco Certified Engineer (ACE501). Apart from shaping Alfresco projects to the requirements of the clients, he keeps himself busy in coordinating Alfresco training program for the new developers at ContCentric.

Leave a reply

Your email address will not be published. Required fields are marked *