Restoring Alfresco: how a backup is used

/ / Blog, Document Management
BeeCon 2016 is approaching fast
Integrating Alfresco with the new Google Vision API

Last week we were working on a load test to upload one million documents to our internal Alfresco server by using 5.1.e release.

However, we forget about our CentOS 6 configuration, which was only accepting 1 million inodes. So, our test were abruptly terminated when there was no more inodes.

$ df -i
Filesystem      Inodes  IUsed   IFree IUse% Mounted on
/dev/vzfs      1000000 997947    2053  100% /
none           1572864    154 1572710    1% /dev

As it was just only a dev server, we thought about restoring our weekly backup produced by our /etc/cron.weekly script.

First of all: get some space free in the system. Current file system for Alfresco repository, including half a million files, was removed.

$ service alfresco stop
$ cd /opt/alfresco 
$ rm -rf alf_data

Time to prepare our backup: postgreSQL dump and alf_data folder packaged together.

$ cd /opt/alfresco-backup
$ cp alfresco-backup-03_14_2016.tar.gz /tmp
$ cd /tmp
$ tar xvf alfresco-backup-03_14_2016.tar.gz
$ cd tmp/03_14_2016
$ ls
alf_data.tar.gz   pgdump_alfresco.sql

With alfresco stopped, a PostgreSQL DUMP restoration can be performed.

$ su - postgres
postgres=# drop database alfresco;
postgres=# CREATE DATABASE alfresco
postgres-# WITH OWNER = postgres
postgres-# ENCODING = 'UTF8'
postgres-# TABLESPACE = pg_default
postgres-# LC_COLLATE = 'es_ES.utf8'
postgres-# LC_CTYPE = 'es_ES.utf8'
postgres-# CONNECTION LIMIT = -1
postgres-# TEMPLATE template0;
postgres=# GRANT ALL ON DATABASE alfresco TO public;
postgres=# GRANT ALL ON DATABASE alfresco TO postgres;
postgres=# GRANT ALL ON DATABASE alfresco TO alfresco;
postgres=# \q

$ psql alfresco < /tmp/tmp/03_14_2016/pgdump_alfresco.sql

$ exit

Once the database is up and ready, alfresco repository file system can be also restored.

$ cd /tmp/tmp/03_14_2016
$ tar xvf alf_data.tar.gz
$ cd opt/alfresco
$ mv alf_data /opt/alfresco

$ service alfresco start

Finally, having tested that our system was working properly, all temporal resources can be removed.

$ cd /tmp
$ rm -rf tmp
$ rm -rf alfresco-backup-03_14_2016.tar.gz

$ df -i
Filesystem      Inodes  IUsed   IFree IUse% Mounted on
/dev/vzfs      1000000 135588  864412   14% /
none           1572864    154 1572710    1% /dev

By using a correct generated and stored Alfresco backup, just 10 minutes are required to bring back to life any Alfresco installation.

This methods may not be ready to production environments, some cautions have been omitted because of our dev environment. However, main steps are equivalent to restore Alfresco in both prod and dev environments.

Unidad de negocio, keensoft

3 Comments to “ Restoring Alfresco: how a backup is used”

  1. Hi Angel,

    Really interesting point about the inodes, I bet that could cause a live system an unfortunate amount of trouble as it’s easy to forget to check 🙂 Especially if the system started smallish and grew over time.

    Just curious, but for high volume Linux-based Alfresco systems, have you seen any issues with the amount of time it takes to actually back up the system? Especially on systems with large numbers of small files? Just interested because I came across a case where a standard COTS backup product was taking ages to take incremental backups – it was taking almost 24 hours to take the incremental backup and spent most of its time scanning the file system for changes. Just wondered if this was an issue you have had to deal with or have come across?


  2. Angel Borroy says :

    Hi Stephen,

    Thanks for your comments.

    Actually this was just a dev server and it’s hosted externally, so we have a very simple backup an restore policy. When using real systems, we use to provide an external filesystem formatted by using BTRFS which is more convenient for incremental backup operations.


  3. Avinash says :

    Hi I am trying to restore my alfresco backup in new alfresco installtion. I have two backup alfbackup_2017-08-10_Thu.sql and antoher one is alf_data. can you please help me regarding this. How to restore this sql backup . and replce the alf_data I am able to do. Please help me!!!!!