Friday 31 May 2013

Alfresco Automated Backup Script Linux

Backups are a pain and as our system is used more and more the need for more regular and controlled backups has been demanding. Doing the system manually for a while has given an idea of where the problems are. We do an automated backup every night of the whole machine, but this does not include an Alfresco database schema and when we have tried to recover the database the solar indexing has made the backups useless.
The basic backup mechanism I have given before, so here is a simple I have been using which works.

I run the script as root and have made a .pgpass file in the root directory with the database password in it.
*:*:*:postgres:topsecret
This file is chmoded at 600

The backup Script for Linux is run by a cron. Each time it is run a new dated backup is made. These are periodically removed as they get to old.

#!/bin/bash
echo "=== Set up the environment ==="

Days=`date +%Y%m%d-%H%M%S`;
Alfresco_root="/opt/alfresco-4.2.c";
Alfresco_repository="$Alfresco_root/alf_data/";
Alfresco_backup_dir="/home/philip/backup";
DB_USER="postgres";
alfresco_db="alfresco";

echo "=== Stopping Alfresco ==="

sh $Alfresco_root/alfresco.sh stop
sleep 240

cd $Alfresco_root/tomcat/shared/classes

echo "=== copying the global properties file ==="
cp alfresco-global.properties.noindex alfresco-global.properties
echo "=== Now restarting and stopping Alfresco to stop indexing ==="

sh $Alfresco_root/alfresco.sh start
sleep 300

echo "=== Alfresco up indexed stopped. Now shutting down ==="
sh $Alfresco_root/alfresco.sh stop

echo "===  Alfresco stopped... ==="
echo "=== Starting Alfresco in Postgres only mode ==="

sh $Alfresco_root/alfresco.sh start postgresql

echo "=== Make Postgres Backup ==="

pg_dump -h localhost -U $DB_USER  $alfresco_db > $Alfresco_backup_dir/alfrescodbdump$Days

sh $Alfresco_root/alfresco.sh stop postgresql
echo "=== Postgres backed up and Alfresco stopped ==="


echo "=== Creating Aflresco Repository Backup ==="


cp $Alfresco_root $Alfresco_backup_dir/alfresco-4.2.c.backup$Days -R
echo "=== copy back the properties file ==="

cp alfresco-global.properties.solr alfresco-global.properties
echo "=== Restarting Alfresco ... All done ==="

cd $Alfresco_root


sh $Alfresco_root/alfresco.sh start 

Wednesday 15 May 2013

Alfresco Global Properties Configuration

A Basic Global Properties file is not very useful. It needs some basic changes before you can use it.
Here is a proposed basic global properties file to start with.

The sites name is myalfresco.dyndns.info





This is what the basic file should look like



###############################
## Common Alfresco Properties #
###############################

dir.root=/opt/alfresco-4.2.c/alf_data

alfresco.context=alfresco
alfresco.host=myalfesco.dyndns.info
alfresco.port=8080
alfresco.protocol=http

share.context=share
share.host=myalfesco.dyndns.info
share.port=8080
share.protocol=http

### database connection properties ###
db.driver=org.postgresql.Driver
db.username=alfresco
db.password=abc1def1
db.name=alfresco
db.url=jdbc:postgresql://localhost:5432/${db.name}

### FTP Server Configuration ###
ftp.enabled=true
ftp.port=2121

### RMI service ports ###
alfresco.rmi.services.port=50500
avm.rmi.service.port=0
avmsync.rmi.service.port=0
attribute.rmi.service.port=0
authentication.rmi.service.port=0
repo.rmi.service.port=0
action.rmi.service.port=0
deployment.rmi.service.port=0

### External executable locations ###
ooo.exe=/opt/alfresco-4.2.c/libreoffice/program/soffice.bin
ooo.enabled=true
ooo.port=8100
img.root=/opt/alfresco-4.2.c/common
img.dyn=${img.root}/lib
img.exe=${img.root}/bin/convert
swf.exe=/opt/alfresco-4.2.c/common/bin/pdf2swf
swf.languagedir=/opt/alfresco-4.2.c/common/japanese

jodconverter.enabled=false
jodconverter.officeHome=/opt/alfresco-4.2.c/libreoffice
jodconverter.portNumbers=8100

### Initial admin password ###
alfresco_user_store.adminpassword=c501f31eae9109c46b0b27f1eb28d15a

### E-mail site invitation setting ###
notification.email.siteinvite=true

### E-mail properties ###
mail.host=smtp.gmail.com
mail.port=465
mail.username=myalfesco@gmail.com
mail.password=topsecret
mail.encoding=UTF-8
mail.from.default=alfresco@myalfesco.dyndns.info
mail.protocol=smtps
mail.smtp.auth=false
mail.smtp.starttls.enable=false

#use these properties to send test message during start of subsystem
mail.testmessage.send=true
mail.testmessage.to=philipmrussell@gmail.com my email address
mail.testmessage.subject=Outbound SMTP System OK
mail.testmessage.text=The Outbound SMTP email subsystem on Alfresco is working.

# Additional Java Mail properties for SMTPS protocol
mail.smtps.auth=true
mail.smtps.starttls.enable=true


#
# Alfresco Email Service and Email Server
#-------------

# Enable/Disable the inbound email service.  The service could be used by processes other than
# the Email Server (e.g. direct RMI access) so this flag is independent of the Email Service.
#-------------
email.inbound.enabled=true

# Email Server properties
#-------------
email.server.enabled=true
email.server.port=25
email.server.domain=myalfesco.dyndns.info
email.inbound.unknownUser=anonymous
email.server.connections.max=3


# A comma separated list of email REGEX patterns of allowed senders.
# If there are any values in the list then all sender email addresses
# must match.
# Allow anyone:
email.server.allowed.senders=.*\@yahoo\.com, .*\@btinternet\.com, .*\@gmail\.com,  .*\@netlab\.co\.uk, .*\@tiscali\.co\.uk.


email.server.allowed.senders=.*

email,server.hideTLS=true
email,server.enableTLS=false
email,server.requireTLS=false

imap.server.enabled=false
imap.server.port=143
imap.server.host=localhost


### License location ###
dir.license.external=/opt/alfresco-4.2.c

### Solr indexing ###
index.subsystem.name=solr
dir.keystore=${dir.root}/keystore
solr.port.ssl=8443

### BPM Engine ###
system.workflow.engine.jbpm.enabled=false