Last active
August 30, 2015 01:04
-
-
Save stefb69/b46adb54e81b8a6b3ef9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SOURCE="/" | |
DESTLABEL="backup-disk" | |
SMOUNTDIR=/mnt/source | |
DMOUNTDIR=/mnt/destination | |
EXCLUDE=/etc/save.exclude | |
[email protected] | |
DBPW="password" | |
RC=0 | |
for MOUNTDIR in ${SMOUNTDIR} ${DMOUNTDIR} ; do | |
echo mounting $MOUNTDIR | |
mount | grep -q "on ${MOUNTDIR}" | |
if [ $? -eq 0 ] | |
then | |
umount ${MOUNTDIR} | |
else | |
echo ${MOUNTDIR} not mounted | |
fi | |
if [ ! -d $MOUNTDIR ] ; then | |
mkdir $MOUNTDIR | |
fi | |
done | |
mount -o bind ${SOURCE} $SMOUNTDIR | |
mount LABEL=${DESTLABEL} $DMOUNTDIR | |
if [ $? -ne 0 ] ; then | |
RC=$(( $RC + 1 )) | |
else | |
echo rsync -aAXv --exclude-from=${EXCLUDE} --delete $SMOUNTDIR/ $DMOUNTDIR/ | |
rsync -aAXv --exclude-from=${EXCLUDE} --delete $SMOUNTDIR/ $DMOUNTDIR/ | |
mysqldump --all-databases -p${DBPW} | lzma > ${DMOUNTDIR}/root/all_db.sql.lzma | |
if [ $? -ne 0 ] ; then | |
RC=$(( $RC + 1 )) | |
fi | |
sync | |
sync | |
echo sleeping 30 secs | |
sleep 30 | |
umount $SMOUNTDIR | |
umount $DMOUNTDIR | |
if [ $? -ne 0 ] ; then | |
RC=$(( $RC + 1 )) | |
fi | |
fi | |
DATE=`date` | |
if [ $RC -eq 0 ] ; then | |
mail -s "Backup OK le ${DATE}" ${EMAIL} <<EOF | |
Le snapshot c'est passe correctement, | |
backup@${HOSTNAME} | |
EOF | |
else | |
mail -s "Probleme de backup le ${DATE}" ${EMAIL} <<EOF | |
Il y a eu un probleme pendant le snapshot, | |
Veuillez prevenir un administrateur | |
backup@${HOSTNAME} | |
EOF | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/dev/* | |
/proc/* | |
/sys/* | |
/tmp/* | |
/run/* | |
/mnt/* | |
/media/* | |
/lost+found |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment