#!/bin/bash
##############################################################################
# #
# Description : Script de sauvegarde d'Alfresco #
# OS : Linux #
# Licence : GPLv3 #
# Version : 1.0.1 #
# Author : Schneider Benoit <ton.ami.totoro CHEZ gmail.com> #
# Web site : https://totorux.info #
# #
# #
# #
# Foobar is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# Foobar is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with Foobar. If not, see <http://www.gnu.org/licenses/>. #
# #
##############################################################################
#Variable
utilmysql=usermysql #Utilisateur Mysql
mdputilmysql=mdpusermysql #Mot de passe de l'utilisateur Mysql
basemysql=–all-databases #Nom de la base Mysql
serveurmysql=localhost #Nom du serveur Mysql
dossiertrav=/tmp/save-alfresco #Dossier de travail
dossiertmp=save-alfresco-`date +%Y-%m-%d` #Dossier & nom de la sauvegarde
dossiersav=/root/save-alfresco #Dossier ou sont deplace les sauvegardes
dossieralfresco=/opt/Alfresco #Dossier ou est installe alfresco
#Nombre de sauvegarde conserver:
nb=5
##Fonctions:
sauv-mysql() #Sauvegarde des bases de donnees
{
echo "Sauvegarde mysql"
echo >> /var/log/save-alfresco.log
echo "Sauvegarde mysql" >> /var/log/save-alfresco.log
mysqldump -u $utilmysql -p$mdputilmysql -h $serveurmysql $basemysql > $dossiertrav/$dossiertmp/alfred-mysql.sql
echo "Fin sauvegarde mysql" >> /var/log/save-alfresco.log
echo "Fin sauvegarde mysql"
echo >> /var/log/save-alfresco.log
}
sauv-data() #Sauvegarde des donnees
{
echo >> /var/log/save-alfresco.log
echo "Sauvegarde data"
echo "Sauvegarde data" >> /var/log/save-alfresco.log
cp -r $dossieralfresco/alf_data $dossiertrav/$dossiertmp/ >> /var/log/save-alfresco.log
echo "Fin sauvegarde data" >> /var/log/save-alfresco.log
echo "Fin sauvegarde data"
echo >> /var/log/save-alfresco.log
}
sauv-conf() #Sauvegarde des donnees
{
echo >> /var/log/save-alfresco.log
echo "Sauvegarde de la configuration d alfresco"
echo "Sauvegarde de la configuration d alfresco" >> /var/log/save-alfresco.log
#Si vous voulez sauvegarder d autres fichiers remplacer / ajouter leurs chemin apres le in dans la boucle si dessous
for conf in $dossieralfresco/alfresco.sh $dossieralfresco/tomcat/shared/classes/alfresco-global.properties $dossieralfresco/tomcat/webapps/alfresco/WEB-INF/classes/log4j.properties
do
echo "Sauvegarde de $conf" >> /var/log/save-alfresco.log
cp -r $conf $dossiertrav/$dossiertmp/ >> /var/log/save-alfresco.log
done
echo "Fin sauvegarde de la configuration d alfresco" >> /var/log/save-alfresco.log
echo "Fin sauvegarde de la configuration d alfresco"
echo >> /var/log/save-alfresco.log
}
sauv-comp() #Compression de la sauvegarde
{
echo >> /var/log/save-alfresco.log
echo "Compression data"
echo "Compression data" >> /var/log/save-alfresco.log
cd $dossiertrav
tar -czvf $dossiertmp.tar.gz $dossiertmp | grep tar: >> /var/log/save-alfresco.log
echo "Fin compression data" >> /var/log/save-alfresco.log
echo "Fin compression data"
}
sauv-ndernier() #Conservation des N dernieres sauvegardes
{
echo >> /var/log/save-alfresco.log
echo "Conservation de $nb derniere sauvegarde"
echo "Conservation de $nb derniere sauvegarde" >> /var/log/save-alfresco.log
cd $dossiersav
nbsav=`ls | wc -l`
echo >> /var/log/save-alfresco.log
echo "Nombre de points de sauvegardes `echo $nbsav`" >> /var/log/save-alfresco.log
if test $nbsav -gt $nb
then
ls $dossiersav > $dossiertrav/nb-sav.txt
tail -n $nb $dossiertrav/nb-sav.txt > $dossiertrav/nb-sav-2.txt
echo >> /var/log/save-alfresco.log
echo "Ne doivent pas etre supprimes" >> /var/log/save-alfresco.log
echo >> /var/log/save-alfresco.log
cat $dossiertrav/nb-sav-2.txt >> /var/log/save-alfresco.log
for sav in `cat $dossiertrav/nb-sav-2.txt`
do
sed -i "/^$sav/"'d' $dossiertrav/nb-sav.txt
done
echo >> /var/log/save-alfresco.log
echo "Suppression des vieilles sauvegardes" >> /var/log/save-alfresco.log
for savenutil in `cat $dossiertrav/nb-sav.txt`
do
rm $dossiersav/$savenutil
echo "Suppression de la sauvegarde $savenutil" >> /var/log/save-alfresco.log
done
rm $dossiertrav/nb-sav*
fi
echo "Fin nettoyage des sauvegarde" >> /var/log/save-alfresco.log
echo "Fin nettoyage des sauvegarde"
}
##Script
echo >> /var/log/save-alfresco.log
echo "<==========Debut nouvelle sauvegarde==========>">> /var/log/save-alfresco.log
echo >> /var/log/save-alfresco.log
echo Debut de la sauvegarde le >> /var/log/save-alfresco.log
date >> /var/log/save-alfresco.log
if [ -d $dossiersav ]
then
if [ -d $dossiertrav ]
then
mkdir -p $dossiertrav/$dossiertmp
else
mkdir $dossiertrav/$dossiertmp
fi
else
mkdir -p $dossiersav
mkdir -p $dossiertrav/$dossiertmp
fi
sauv-mysql
echo "Fin sauvegarde mysql debut sauvegarde des donnees le" >> /var/log/save-alfresco.log
date >> /var/log/save-alfresco.log
sauv-data
echo "Fin sauvegarde des donnees le" >> /var/log/save-alfresco.log
date >> /var/log/save-alfresco.log
sauv-conf
echo "Fin sauvegarde des fichiers de configuration, debut compression de la sauvegarde le" >> /var/log/save-alfresco.log
date >> /var/log/save-alfresco.log
sauv-comp
mv $dossiertrav/$dossiertmp.tar.gz $dossiersav
rm -rf $dossiertrav/$dossiertmp
sauv-ndernier
echo >> /var/log/save-alfresco.log
echo "Fin de la sauvegarde le" >> /var/log/save-alfresco.log
date >> /var/log/save-alfresco.log
echo >> /var/log/save-alfresco.log
echo "<==========Fin nouvelle sauvegarde==========>">> /var/log/save-alfresco.log
echo >> /var/log/save-alfresco.log
echo "*********************************************">> /var/log/save-alfresco.log
#!/bin/bash
##############################################################################
# #
# Description : Script de restauration d'Alfresco #
# OS : Linux #
# Licence : GPLv3 #
# Version : 0.1.0 #
# Author : Schneider Benoit <ton.ami.totoro CHEZ gmail.com> #
# Web site : https://totorux.info #
# #
# #
# #
# Foobar is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# Foobar is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with Foobar. If not, see <http://www.gnu.org/licenses/>. #
# #
##############################################################################
##Variable
utilmysql=usermysql #Utilisateur Mysql
mdputilmysql=mdpusermysql #Mot de passe de l'utilisateur Mysql
basemysql=–all-databases #Nom de la base Mysql
serveurmysql=localhost #Nom du serveur Mysql
dossiertrav=/tmp/save-alfresco #Dossier de travail
dossiersav=/root/save-alfresco #Dossier ou sont les sauvegardes
dossieralfresco=/opt/Alfresco #Dossier ou est installe alfresco
nbrest=0
##Fonctions
list-sav() #Listage des sauvegardes
{
echo Liste des sauvegardes
mkdir -p $dossiertrav >> /var/log/save-alfresco.log
cd $dossiersav
nbsav=`ls | wc -l`
ls $dossiersav > $dossiertrav/nbsave.txt
echo "Il y a $nbsav sauvegardes"
echo "Il y a $nbsav sauvegardes" >> /var/log/save-alfresco.log
for sav in `cat $dossiertrav/nbsave.txt`
do
nbrest=$(($nbrest + 1 ))
echo $nbrest >> $dossiertrav/list.txt
echo "$nbrest : $sav"
done
echo Fin Liste sauvegardes
}
recup-sav() #Requperation sauvegarde
{
echo Requperation sauvegarde
echo "Indiquez le numéro du point de sauvegarde à restaurer"
read choix
if [ -z "`echo $choix | sed s/[0-9]*//`" ]
then
if test $choix -lt 1 -o $choix -gt $nbsav
then
echo "Restauration annulée, mettez un des chiffres contenus dans la liste" && exit
fi
else
echo "Restauration annulée, mettez un des chiffres contenus dans la liste" && exit
fi
arg=`echo $choix`p
sed -n "$arg" $dossiertrav/nbsave.txt > $dossiertrav/arestaurer.txt
echo Fin Requperation sauvegarde
}
decomp-data() #decompresion de la sauvegarde
{
echo Decompresion de la sauvegarde
echo "Début restauration de la sauvegarde `cat $dossiertrav/arestaurer.txt`" >> /var/log/save-alfresco.log
cp $dossiersav/`cat $dossiertrav/arestaurer.txt` $dossiertrav/ >> /var/log/save-alfresco.log
tar -xzvf $dossiertrav/`cat $dossiertrav/arestaurer.txt` -C $dossiertrav/ | grep tar: >> /var/log/save-alfresco.log
sed -i "s/.tar.gz//" $dossiertrav/arestaurer.txt
echo Fin decompresion de la sauvegarde
}
resto-data() #Restauration des donnees
{
echo Restauration data
mv $dossieralfresco/alf_data $dossiertrav/alf_data-`date +%Y-%m-%d`
mv $dossiertrav/`cat $dossiertrav/arestaurer.txt`/alf_data $dossieralfresco/
mv $dossieralfresco/alf_data/backup-lucene-indexes $dossieralfresco/alf_data/lucene-indexes
echo Fin restauration data
}
resto-base() #Restauration de la base de donnees
{
echo Restauration de la base de donnees
mysql -u $utilmysql -p$mdputilmysql -e "drop database alfresco;"
mysql -u $utilmysql -p$mdputilmysql -e "create database alfresco;"
mysql -u $utilmysql -p$mdputilmysql alfresco < $dossiertrav/`cat $dossiertrav/arestaurer.txt`/alfred-mysql.sql
echo Fin restauration de la base de donnees
}
net-tmp() #Nettoyage du dossier temporaire
{
echo Debut nettoyage du dossier temporaire
rm -rf $dossiertrav/`cat $dossiertrav/arestaurer.txt`
for fichier in arestaurer.txt list.txt nbsave.txt
do
rm $dossiertrav/$fichier
done
echo Voulez vous suprimez la sauvegarde du alf_data creer a l instant oui/Oui ou non/Non ?
read reponse
case "$reponse" in
oui|Oui)
rm -rf $dossiertrav/alf_data-*
echo "Dossier alf_data tu dossier de travail suprimez"
;;
non|Non)
echo "Dossier non surprimer"
;;
*)
echo "valeur invalide"
esac
echo Fin nettoyage du dossier temporaire
}
##Script
##Arret d'Alfresco
echo >> /var/log/save-alfresco.log
echo "<==========Debut restauration==========>">> /var/log/save-alfresco.log
echo >> /var/log/save-alfresco.log
echo >> /var/log/save-alfresco.log
echo "Début restauration, arret d alfresco le `date +%Y-%m-%d_%Hh%M`" >> /var/log/save-alfresco.log
echo >> /var/log/save-alfresco.log
$dossieralfresco/alfresco.sh stop >> /var/log/save-alfresco.log
killall java >> /var/log/save-alfresco.log
echo >> /var/log/save-alfresco.log
#Listage des sauvegardes
list-sav
#Récupération de la sauvegarde a restaurer
recup-sav
#Décompression de la sauvegarde
decomp-data
##Restoration des donnees
resto-data
##Restoration de la base de donnee
resto-base
net-tmp
##Demarage d'Alfresco
echo >> /var/log/save-alfresco.log
echo "Redemarrage d alfresco" >> /var/log/save-alfresco.log
echo >> /var/log/save-alfresco.log
echo "Fin de la restauration redemarrage d alfresco !"
$dossieralfresco/alfresco.sh start >> /var/log/save-alfresco.log
echo >> /var/log/save-alfresco.log
echo "Fin restauration, alfresco redemarrer le `date +%Y-%m-%d_%Hh%M`" >> /var/log/save-alfresco.log
echo "<==========Fin restauration==========>">> /var/log/save-alfresco.log
echo >> /var/log/save-alfresco.log
echo "*********************************************">> /var/log/save-alfresco.log
HTTP Status 404 -
type Status report
message
description The requested resource () is not available.
Apache Tomcat/6.0.18
index.recovery.mode=FULL
# Directory to Store
mkdir -p $BACKUP_DESTINATION_BASE 2>> $LOGFILE
if [ $? -gt 0 ] ; then
message "$ERROR : Unable to create the destination directory"
exit 1
fi
# Save the database
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
message "$ERROR : Unable to do the mysqldump"
exit 1
fi
index.recovery.mode=FULL
@ +
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.