This commit is contained in:
Bob Mottram 2016-07-10 09:42:39 +01:00
parent b62ffd74b6
commit 56fff9a6cd
1 changed files with 18 additions and 15 deletions

View File

@ -37,6 +37,7 @@ ENABLE_VERIFICATION="no"
export TEXTDOMAIN=${PROJECT_NAME}-backup-remote export TEXTDOMAIN=${PROJECT_NAME}-backup-remote
export TEXTDOMAINDIR="/usr/share/locale" export TEXTDOMAINDIR="/usr/share/locale"
# utilities needed for backup commands
UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-* UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*
for f in $UTILS_FILES for f in $UTILS_FILES
do do
@ -102,19 +103,20 @@ function restart_site {
function backup_configuration { function backup_configuration {
echo $"Backing up ${PROJECT_NAME} configuration files" echo $"Backing up ${PROJECT_NAME} configuration files"
if [ ! -d /root/tempbackupconfig ]; then temp_backup_dir=/root/tempbackupconfig
mkdir -p /root/tempbackupconfig if [ ! -d $temp_backup_dir ]; then
mkdir -p $temp_backup_dir
fi fi
cp -f $CONFIG_FILE /root/tempbackupconfig cp -f $CONFIG_FILE $temp_backup_dir
cp -f $COMPLETION_FILE /root/tempbackupconfig cp -f $COMPLETION_FILE $temp_backup_dir
if [ -f $BACKUP_EXTRA_DIRECTORIES ]; then if [ -f $BACKUP_EXTRA_DIRECTORIES ]; then
cp -f $BACKUP_EXTRA_DIRECTORIES /root/tempbackupconfig cp -f $BACKUP_EXTRA_DIRECTORIES $temp_backup_dir
fi fi
# nginx password hashes # nginx password hashes
if [ -f /etc/nginx/.htpasswd ]; then if [ -f /etc/nginx/.htpasswd ]; then
cp -f /etc/nginx/.htpasswd /root/tempbackupconfig/htpasswd cp -f /etc/nginx/.htpasswd $temp_backup_dir/htpasswd
fi fi
backup_directory_to_friend /root/tempbackupconfig config backup_directory_to_friend $temp_backup_dir config
} }
function backup_users { function backup_users {
@ -278,20 +280,21 @@ function backup_admin_readme {
function backup_mariadb { function backup_mariadb {
if [ ${#DATABASE_PASSWORD} -gt 1 ]; then if [ ${#DATABASE_PASSWORD} -gt 1 ]; then
if [ ! -d /root/tempmariadb ]; then temp_backup_dir=/root/tempmariadb
mkdir /root/tempmariadb if [ ! -d $temp_backup_dir ]; then
mkdir $temp_backup_dir
fi fi
mysqldump --password=$DATABASE_PASSWORD mysql user > /root/tempmariadb/mysql.sql mysqldump --password=$DATABASE_PASSWORD mysql user > $temp_backup_dir/mysql.sql
if [ ! -s /root/tempmariadb/mysql.sql ]; then if [ ! -s $temp_backup_dir/mysql.sql ]; then
echo $"Unable to backup MariaDB settings" echo $"Unable to backup MariaDB settings"
rm -rf /root/tempmariadb rm -rf $temp_backup_dir
# Send a warning email # Send a warning email
echo $"Unable to export database settings" | mail -s "${PROJECT_NAME} backup to friends" $ADMIN_EMAIL_ADDRESS echo $"Unable to export database settings" | mail -s "${PROJECT_NAME} backup to friends" $ADMIN_EMAIL_ADDRESS
exit 653 exit 653
fi fi
echo "$DATABASE_PASSWORD" > /root/tempmariadb/db echo "$DATABASE_PASSWORD" > $temp_backup_dir/db
chmod 400 /root/tempmariadb/db chmod 400 $temp_backup_dir/db
backup_directory_to_friend /root/tempmariadb mariadb backup_directory_to_friend $temp_backup_dir mariadb
fi fi
} }