04-29-2016 11:27 AM
Alfresco backup
1. cd /opt/alfresco-community
2. ./alfresco.sh stop // stop Alfresco
3. ./alfresco.sh start postgresql // start postgresql
4. /opt/alfresco-community/postgresql/bin/pg_dump -U alfresco -w -F t -b alfresco > /tmp/postgres.dump.tar // backup postgresql DB
5. ./alfresco.sh stop postgresql // stop postgresql
6. tar -cvf /tmp/alf_data-contentstore.tar alf_data/contentstore // backup content store
7. tar -cvf /tmp/alf_data-contentstore.deleted.tar alf_data/contentstore.deleted // backup content store deleted items
8. cp alfresco-global.properties /tmp // save copy of alfresco-global.properties
9. cp bin/apply_amps.sh /tmp // save copy of apply_amps.sh
10. cp alfresco.sh /tmp // save copy of alfresco.sh
11. ./alfresco.sh start
Alfresco restore
1. Install Alfresco
2. cd /opt/alfresco-community
3. ./alfresco.sh stop // stop Alfresco
4. ./alfresco.sh start postgresql // start postgresql
5. su - postgres
/opt/alfresco-community/postgresql/bin/psql
DROP DATABASE alfresco;
CREATE DATABASE alfresco WITH OWNER alfresco;
ctrl-d (exit)
6. /opt/alfresco-community/postgresql/bin/psql -U alfresco -d alfresco
ALTER USER alfresco WITH PASSWORD 'alfresco';
ctrl-d (exit)
7. /opt/alfresco-community/postgresql/bin/pg_restore -w /tmp/postgres.dump.tar
8. exit // from postgres ID
9. cd /opt/alfresco-community
10. ./alfresco.sh stop postgresql // stop postgresql
11. tar -xvf /tmp/alf_data-contentstore.tar
12. tar -xvf /tmp/alf_data-contentstore.deleted.tar
13. rm -f /opt/alfresco-community/alf_data/solr4/index/workspace/SpacesStore/index/*
14. rm -f /opt/alfresco-community/alf_data/solr4/index/archive/SpacesStore/index/*
15. rm -f /opt/alfresco-community/alf_data/solr4/model/*.xml
16. rm -Rf /opt/alfresco-community/alf_data/solr4/content/_DEFAULT_
17. cp /tmp/alfresco-global.properties /opt/alfresco-community/tomcat/shared/classes
18. cp /tmp/apply_amps.sh /opt/alfresco-community/bin
19. cp /tmp/alfresco.sh /opt/alfresco-community
20. ./alfresco.sh start
04-29-2016 11:31 AM
04-29-2016 06:33 PM
02-23-2017 01:03 PM
I had the same problem and solved it using the information I gathered and customized. I backed up the entire alf_data directory in my process which is:
Alfresco-Community Cold Backup and Restore from a cold backup process
orginally posted by Francesco Corti in 2013
In the Alfresco wiki is described the backup and restore strategy but is not so clear how to do it in detail. In this post is shared a practical way to perform a restore of a backed up Alfresco in the way I like: a list of commands and tasks to execute… simpler to understand, to do and to test.
In this example is supposed that Alfresco-Community 201609 EA is installed in ‘/opt/alfresco-community’ folder and the DBMS used is PostgreSQL included with the installer. The restore strategy supposes that the backup is done as a “cold backup” described in this script:
#!/bin/bash
# Backup of Alfresco
# Written by Chris Newald – localized by Clint Davis Feb 2017
# Configuration:
CURRENT_FOLDER=$(pwd) # Script folder
TIMESTAMP=$( date +%Y%m%d%H%M%S ) # Create timestamp
DUMP_NUM=10 # Number of backups to keep
AL_FOLDER="/opt/alfresco-community" # Alfresco folder
AL_DATA="/opt/alfresco-community/alf_data" # Alfresco data folder
TARGET_FOLDER=”/backup” # Backup destination folder
DB_HOME="/opt/alfresco-community/postgresql" # PostgreSQL folder
# Function - Stop Alfresco
function al_stop()
{
$AL_FOLDER/alfresco.sh stop
# If Alfresco does not stop we MUST exit script
# Backing up files with Alfresco working may
# corrupt data indexes!!
if [ "$?" != "0" ]; then
echo "Alfresco Stop FAILED - STOP SCRIPT!"
exit 1
else
# Alfresco Stopped successfully
echo “Alfresco Stop successful!”
fi
}
# Function - Start Alfresco
function al_start()
{
$AL_FOLDER/alfresco.sh start
}
# Function - Start Postgress SQL Server
function p_start()
{
$DB_HOME/scripts/ctl.sh start
}
# Verify that argument was provided
if [ -d "$1" ]; then
# A folder has been provided, save it
TARGET_FOLDER="$1"
else
# No argument was provided for backup location
echo "Usage: $0 [TARGET_PATH]"
exit 0
fi
#----------------------------------------
# 1 - Begin by stopping Alfresco
#----------------------------------------
al_stop
#----------------------------------------
# 2 - Backup the Alfresco database
#----------------------------------------
# Start the postgress database (which is stopped automatically
# by the Alfresco stop script
p_start
# Create a filename for the database tar
DB_DUMP=alfresco_db_${TIMESTAMP}.tar
# Backup the database to the target folder
# -Ft = Export database as tar file
$DB_HOME/bin/pg_dump alfresco -U alfresco -h localhost -F t > $TARGET_FOLDER/$DB_DUMP
# Check if an error was returned
if [ "$?" = "0" ]; then
echo "DB EXPORT WORKED!"
else
echo "DB EXPORT FAILED!"
fi
#------------------------------------------
# 3 - Backup the Alfresco content folder
#------------------------------------------
# Create a file name with timestamp
AL_DUMP=alfresco_data_${TIMESTAMP}.tgz
# Tar the Alfresco data folder to the backup
# to the backup folder specified
tar zcf $TARGET_FOLDER/$AL_DUMP $AL_DATA
echo "Alfresco Data folder tar complete"
#------------------------------------------
# 4 - Merge the database and data files
#------------------------------------------
# Create a backup filename with timestamp
BACKUP_FILE="alfresco_bak_${TIMESTAMP}.tgz"
tar zcf $TARGET_FOLDER/$BACKUP_FILE $TARGET_FOLDER/$AL_DUMP $TARGET_FOLDER/$DB_DUMP
echo "Database and Data File merge complete"
# If files were merged, delete the duplicates
if [ -f "$TARGET_FOLDER/$BACKUP_FILE" ]; then
echo "BACKUP SUCCESSFUL"
rm $TARGET_FOLDER/$AL_DUMP
rm $TARGET_FOLDER/$DB_DUMP
SUCCESS=1
fi
#------------------------------------------
# 5 - We're done, start the Alfresco service
#------------------------------------------
al_start
#------------------------------------------
# 6 - Remove backups older than DUMP_NUM days
#------------------------------------------
if [ "$SUCCESS" = 1 ]; then
find $TARGET_FOLDER/*.tgz -type f -mtime +${DUMP_NUM} -exec rm {} \;
echo "Backups older than 10 days have been removed"
fi
****************************************************************************************************************************************************************
NOW LET’S RESTORE FROM BACKUP FILES
The following Restore process and script was posted by Francesco Corti in 2013 and was localized by Clint Davis in February 2017.
First of all log in as root user.
1.) Find the backup merged db and data file named “alfresco_bak_yyyymmddtttttt.tgz” and copy it local to Alfresco server in /opt/alfresco-community/postgresql/temp/
2.) issue terminal command “tar –xvf alfresco_bak_yyyymmddtttttt.tgz” to extract the folder named ‘backup’ which contains your alfresco data and postgresql database backup files.
3.) Note the file names for use in the commands following.
Now Stop Alfresco-Community:
service alfresco stop
The DBMS runs using the ‘postgres’ user. Proceed with first task to restore the PostgreSQL database.
su – postgres
cd /opt/alfresco-community/postgresql/scripts
./ctl.sh start
cd /opt/alfresco-community/postgresql/bin
./psql (enter password for user 'postgres' when prompted)
DROP DATABASE alfresco;
CREATE DATABASE alfresco WITH OWNER alfresco;
Digit CTRL+d to exit from the shell.
./psql -U alfresco -d alfresco (enter password for user 'postgres' when prompted)
ALTER USER alfresco WITH PASSWORD 'alfresco password'; (use the admin password for user alfresco here)
Digit CTRL+d to exit from the shell. Supposing the DBMS backup is stored in the ‘alfresco_db_yyyymmddtttttt.tar’ file conforming to the backup strategy described above, let’s go ahead with the restoring of the database.
./pg_restore -d alfresco /opt/alfresco-community/postgresql/temp/backup/alfresco_db_yyyymmddtttttt.tar
(enter password for user 'postgres' when prompted)
exit
Now it’s time to restore the ‘alf_data’ folder with documents and indexes. Also in this case is supposed that the files are stored in a ‘alfresco_data_yyyymmddtttttt.tgz’ file conforming to the backup strategy described above.
cd /opt/alfresco-community
mv alf_data alf_data.old
cd /
tar zxvf /opt/alfresco-community/postgresql/temp/backup/alfresco_data_yyyymmddtttttt.tgz
That’s all!
Now it’s time to start again Alfresco and use it normally.
service alfresco start
03-14-2017 06:42 AM
I guys, noob here; just wondering: "Why aren't you using the cool script «BART» to manage backups"?
I've tried and it seems to work (backed up my alfresco install, made a fresh updated install, restored the data, everything seems to work quite well....)
Give it a try; you'll probably need to implement the restore part you are already wrote on your posts cause it's not yet implemented in the script, but it seems to manage quiet well all the backing up process...
07-20-2017 02:42 PM
This solution helps me with this task, but I needed alfresco backup and restore script but in the forum, I don't found a solution I decided to create this scripts and now this available on https://github.com/bruno-oliveira1 I hope yours enjoying.
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.