#!/bin/bash
# (C) 2008 Guy Rutenberg
# Modified by Lorinthe for backup of Elgg database
DB_NAME=xxx
DB_USER=xxx
DB_PASS=xxx
DB_HOST=localhost
DATA_DIR=/var/elggdata/
BACKUP_DIR=/var/backups/
FTP_HOST=xx.xx.xx.xx
FTP_USER=xxx
FTP_PASS=xxx
FTP_BACKUP_DIR=/httpdocs/
# end of configuration - you probably don't need to touch anything bellow
DATA_DIR=`dirname "$DATA_DIR"`/`basename "$DATA_DIR"`
BACKUP_DIR=`dirname "$BACKUP_DIR"`/`basename "$BACKUP_DIR"`
echo -n "dumping database... "
DUMP_NAME=${DB_NAME}-$(date +%Y%m%d).sql.bz2
mysqldump --user=${DB_USER} --password=${DB_PASS} --host=${DB_HOST} \
--databases ${DB_NAME} \
| bzip2 -c > ${BACKUP_DIR}/${DUMP_NAME}
if [ "$?" -ne "0" ]; then
echo "failed!"
exit 1
fi
echo "done"
echo -n "Creating tarball... "
TAR_NAME=${DB_NAME}-$(date +%Y%m%d)-${DATA_DIR##*/}.tar.bz2
tar -cjf ${BACKUP_DIR}/${TAR_NAME} ${DATA_DIR}
if [ "$?" -ne "0" ]; then
echo "failed!"
exit 2
fi
echo "done"
echo -n "Uploading SQL dump and tarball to FTP... "
lftp -u ${FTP_USER},${FTP_PASS} ${FTP_HOST} <<EOF
cd "${FTP_BACKUP_DIR}"
put "${BACKUP_DIR}/${DUMP_NAME}"
put "${BACKUP_DIR}/${TAR_NAME}"
EOF
if [ "$?" -ne "0" ]; then
echo "failed!"
exit 3
fi
echo "done"
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.