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.
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:
Backup of Alfresco involves two things:
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 ContCentric IT Services Pvt. Ltd.- http//www.contcentric.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:
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.
October 14, 2022
September 15, 2022
August 29, 2022
August 26, 2022
August 9, 2022
We are seeking dynamic professionals and unstoppable talents to craft distinct solutions for our clients to enhance their businesses. Come, join our fair & focused, optimistic & thoughtful world and deliver excellence together.