Creating and Restoring Backups for Alfresco with Docker Compose

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating and Restoring Backups for Alfresco with Docker Compose

angelborroy
Alfresco Employee
2 7 1,887

This blog post describes required operations in order to create and restore an ACS Backup when using Docker Compose deployments.

Following project has been used in order to generate the Docker Compose templates:

https://github.com/alfresco/alfresco-docker-installer

Creating Initial ACS Deployment

In order to create the initial ACS Deployment, just use the Yeoman generator provided by Alfresco with default options.

$ mkdir alfresco-1
$ cd alfresco-1

$ yo alfresco-docker-installer ? Which ACS version do you want to use? 6.2 ? How may GB RAM are available for Alfresco (8 is minimum required)? 12 ? Do you want to use HTTPs for Web Proxy? No ? What is the name of your server? localhost ? What HTTP port do you want to use (all the services are using the same port)? 80 ? Do you want to use FTP (port 2121)? No ? Do you want to use MariaDB instead of PostgreSQL? No ? Are you using different languages (this is the most common scenario)? Yes ? Do you want to create an internal SMTP server? No ? Do you want to create an internal LDAP server? No ? Select the addons to be installed: ? Are you using a Windows host to run Docker? No ? Do you want to use a start script? No

Add the following lines in the volumes section for the service solr6 in generated docker-compose.yml file.

solr6:
...
    volumes:
        - ./data/solr-data:/opt/alfresco-search-services/data
        - ./backup/solr/alfresco:/opt/alfresco-search-services/backup/alfresco
        - ./backup/solr/archive:/opt/alfresco-search-services/backup/archive

This volumes will be used to store the solr backup.

Start the deployment and verify everything is up & running.

$ docker-compose up --build --force-recreate

Use the Share Web Application to add some new folders and files to the repository. By default this application is available in http://localhost/share

Creating an ACS Backup

Alfresco Backups must be performed following the next order:

  • SOLR Cores
  • Database
  • Filesystem

If you are using SOLR Cores for alfresco and archive, you need to perform a backup for every core using SOLR REST API.

$ curl -u admin:admin "http://localhost/solr/alfresco/replication?command=backup&location=/opt/alfresco-search-services/backup/alfresco/&numberToKeep=1&wt=xml"
$ curl -u admin:admin "http://localhost/solr/archive/replication?command=backup&location=/opt/alfresco-search-services/backup/archive/&numberToKeep=1&wt=xml"

If both commands are sucessfully executed, following folders will be available in your local host.

$ tree -L 3 backup
backup
├── solr
    ├── alfresco
    │   └── snapshot.20210216150258667
    └── archive
        └── snapshot.20210216150306103

Once Solr backup is ready, perform a Postgres Dump (Database) using following command.

$ docker-compose exec postgres pg_dump --username alfresco alfresco > backup/pg-dump.sql

You can use some other approach, like zipping the output of the dump, but we are using the simplest one.

Finally, filesystem needs to be saved. The following command is using rsync program in order to get this done.

$ rsync -r data/alf-repo-data backup

At this point your ACS Backup is complete. You'll find all the elements living in backup folder.

$ tree -L 3 backup
backup
├── alf-repo-data
│   ├── contentstore
│   └── contentstore.deleted
├── pg-dump.sql
└── solr
    ├── alfresco
    │   └── snapshot.20210216150258667
    └── archive
        └── snapshot.20210216150306103

Restoring the Backup in a new deployment

Create a new Docker Compose deployment in order to restore your backup.

$ mkdir alfresco-2
$ cd alfresco-2

$ yo alfresco-docker-installer
? Which ACS version do you want to use? 6.2
? How may GB RAM are available for Alfresco (8 is minimum required)? 12
? Do you want to use HTTPs for Web Proxy? No
? What is the name of your server? localhost
? What HTTP port do you want to use (all the services are using the same port)? 80
? Do you want to use FTP (port 2121)? No
? Do you want to use MariaDB instead of PostgreSQL? No
? Are you using different languages (this is the most common scenario)? Yes
? Do you want to create an internal SMTP server? No
? Do you want to create an internal LDAP server? No
? Select the addons to be installed:
? Are you using a Windows host to run Docker? No
? Do you want to use a start script? No

In order to restore Postgres dump, we need to start only postgres service.

$ docker-compose up postgres

Once the new database is ready, restore the backup we dumped in the previous section.

$ cat ../alfresco-1/backup/pg-dump.sql | docker-compose exec -T \
postgres psql --username alfresco --password alfresco 

As it has been described above, you can use some other approach in order to restore the Postgres backup. This one is using a plain text file.

Stop again postgres service when the restore is done.

$ docker-compose stop postgres

In order to restore the filesystem, just copy the saved folder to alf-repo-data.

$ cp -r ../alfresco-1/backup/alf-repo-data data/

Finally, SOLR cores backup need to be restored using the expected names (alfresco and archive).

$ mkdir -p data/solr-data/alfresco
$ cp -r ../alfresco-1/backup/solr/alfresco data/solr-data
$ mv data/solr-data/alfresco/snapshot.20210216150258667 data/solr-data/alfresco/index

$ mkdir -p data/solr-data/archive
$ cp -r ../alfresco-1/backup/solr/archive data/solr-data/
$ mv data/solr-data/archive/snapshot.20210216150306103 data/solr-data/archive/index

Folder data should contain following structure after performing these steps.

$ tree -L 2 data
data
├── alf-repo-data
│   ├── contentstore
│   └── contentstore.deleted
├── postgres-data
└── solr-data
    ├── alfresco
    └── archive

Every persisted information is available in the right place at this point, so you can start your ACS in order to check that everything has been restored.

$ docker-compose up --build --force-recreate

Use again Alfresco Share Web Application in order to verify the contents (by default available in http://localhost/share).

7 Comments
marcosfgo25
Active Member

Hi,

First thank you for this great work.

I am trying to make this backup for alfresco-community edition 7.0 without ssl and when i try this command

curl -u admin:admin "http://localhost/solr/alfresco/replication?command=backup&location=/opt/alfresco-search-services/backup/alfresco/&numberToKeep=1&wt=xml"

I got this output

<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader"><int name="status">0</int><int name="QTime">1</int></lst><str name="status">OK</str>
</response>

and no file created on backup/solr/alfresco dir.

Sorry for my english.

In advance thank you for your time.

angelborroy
Alfresco Employee

Did you created the backup volumes?

        - ./backup/solr/alfresco:/opt/alfresco-search-services/backup/alfresco
        - ./backup/solr/archive:/opt/alfresco-search-services/backup/archive
marcosfgo25
Active Member

yes,  and all the dir was created after i run the alfresco

administrator@alfresco:~/alfresco$ tree -L 3 backup/
backup/
└── solr
├── alfresco
└── archive

 

 

angelborroy
Alfresco Employee

If you are using Linux, probably you need to set those folder permissions to "solr" user:

https://github.com/alfresco/alfresco-docker-installer#docker-volumes

 

marcosfgo25
Active Member

yes you are right after setup permissions the backups run greate, thank you for your time.

Smiley Very HappySmiley Very HappySmiley Very Happy

 

marcosfgo25
Active Member

Hi again, Please help me in other topic with file template problem.

https://hub.alfresco.com/t5/alfresco-content-services-forum/alfresco-content-application-file-and-fo...

marcosfgo25
Active Member

Hi, after all process when i restore the backup files some search feutures was not working good. And i get somes errror:

2021-04-27 12:08:39,018 ERROR [api.search.SearchApiWebscript] [http-nio-8080-exec-7] a95b45f7-427b-4721-a4fa-e1a4a47cf01c :

solr6_1 | 2021-04-27 12:34:10.398 ERROR (qtp119358627-17) [ ] o.a.s.s.HttpSolrCall nullSmiley Surprisedrg.apache.solr.core.SolrCoreInitializationException: SolrCore 'alfresco' is not available due to init failure: java.nio.file.AccessDeniedException: /opt/alfresco-search-services/data/alfresco/snapshot_metadata

 

Sorry i solve this by change permission on all content inside sorl-data folder before move alfresco and archive to index

inside solr-data i runed this code

sudo chown -R 33007:33007 *