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