#!/bin/bash
#—————————————————————#
# Script de backup à froid d'Alfresco #
#—————————————————————#
#
#
#
# Configuration des parametres
#
ALF_DATA_BASE=/var/lib/alfresco
ALF_DATA_DIRNAME=alf_data
BACKUP_DIR=/backups
TEMPORAIRE=/backups/tmp
MACHINE="$(hostname)"
DATE=DATE="$(date +"%d-%m-%Y")"
FICHIER_BACKUP=$MACHINE"_BACKUP_ALFRESCO_"$DATE".tar.gz"
DB_USERNAME=alfresco
DB_PWD=alfresco
DB_NAME=alfresco
OPTIONS=" –complete-insert –routines –triggers –allow-keywords –max_allowed_packet=50M –force"
INCREMENTDIR=`date +%Y-%m-%d_%Hh%M`
LOGFILE=/var/log/backup/backup-$DB_NAME-$INCREMENTDIR.log
#
# Fonctions
#
do_logging()
{
echo "***" >> $LOGFILE
echo "Sauvegarde du $INCREMENTDIR " >> $LOGFILE
echo " " >> $LOGFILE
echo "################################################" >> $LOGFILE
du -chs $BACKUP_DIR/* >> $LOGFILE
echo "################################################" >> $LOGFILE
FIN=`date +%Y-%m-%d_%Hh%M`
echo " " >> $LOGFILE
echo "Sauvegarde fini le $FIN" >> $LOGFILE
echo " " >> $LOGFILE
df -h $ARCHIVEDEV >> $LOGFILE
echo >> $LOGFILE
echo " " >> $LOGFILE
echo "***" >> $LOGFILE
}
rm -f /backups/tmp/alfresco*
/etc/init.d/tomcat5 stop
echo "Arrêt de Tomcat Serveur à " `date +%H:%M` >> $LOGFILE
echo " " >> $LOGFILE
echo "Début du dump de la base "$DB_NAME" à " `date +%H:%M` >> $LOGFILE
echo " " >> $LOGFILE
for db in $DB_NAME
do
mysqlcheck -u $DB_USERNAME -p$DB_PWD -c -a $db
mysqldump -u $DB_USERNAME -p$DB_PWD $OPTIONS $db -R > $TEMPORAIRE"/"$DB_NAME"-"$INCREMENTDIR".sql";
done
echo "Fin du dump de la base "$DB_NAME" Ã " `date +%H:%M` >> $LOGFILE
echo " " >> $LOGFILE
rsync -a /var/lib/alfresco /backups/tmp/
#Creation de l archive contenant les dumps
if [ -d $BACKUP_DIR ]; then
cd $TEMPORAIRE
tar -cvzf $BACKUP_DIR"/"$FICHIER_BACKUP *
fi
/etc/init.d/tomcat5 start
echo "Démarrage de Tomcat Serveur à " `date +%H:%M` >> $LOGFILE
do_logging
vous ne gérez pas le cas ou tomcat ne s'arrete pas correctement pour une raison ou une autre, le script procédera au backup dans tous les cas, ce n'est pas une bonne pratique.
mysqldump -u $MYSQL_USER -p$MYSQL_PASSWORD $MYSQL_DATABASE_ALF –opt –single-transaction –create-options > $BACKUP_FILE_MYSQL_SLQ 2>> $LOGFILE
if [ $? -gt 0 ] ; then
echo "ERROR : Unable to do the mysqldump" >> $LOGFILE
exit 1
fi
Content from pre 2016 and from language groups that have been closed.
Content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.