This commit is contained in:
Bob Mottram 2015-12-11 09:14:33 +00:00
parent e3a7b9ab4e
commit dbb6eb21ec
1 changed files with 83 additions and 73 deletions

View File

@ -55,18 +55,18 @@ fi
function update_domains { function update_domains {
MICROBLOG_DOMAIN_NAME='microblog' MICROBLOG_DOMAIN_NAME='microblog'
if grep -q "GNU Social domain" $COMPLETION_FILE; then if grep -q "GNU Social domain" $COMPLETION_FILE; then
MICROBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "GNU Social domain" | awk -F ':' '{print $2}') MICROBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "GNU Social domain" | awk -F ':' '{print $2}')
fi fi
HUBZILLA_DOMAIN_NAME='hubzilla' HUBZILLA_DOMAIN_NAME='hubzilla'
if grep -q "Hubzilla domain" $COMPLETION_FILE; then if grep -q "Hubzilla domain" $COMPLETION_FILE; then
HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Hubzilla domain" | awk -F ':' '{print $2}') HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Hubzilla domain" | awk -F ':' '{print $2}')
fi fi
FULLBLOG_DOMAIN_NAME='blog' FULLBLOG_DOMAIN_NAME='blog'
if grep -q "Blog domain" $COMPLETION_FILE; then if grep -q "Blog domain" $COMPLETION_FILE; then
FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}') FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
fi fi
} }
function mount_drive { function mount_drive {
@ -347,6 +347,72 @@ function remove_backup_directory {
fi fi
} }
function prepare_directories {
# Some miscellaneous preparation for backing up directories
if [ -d /home/git/go/src/github.com/gogits ]; then
mv /home/git/gogs-repositories/*.git /home/git/gogs-repositories/$ADMIN_USERNAME
fi
if [ -d /var/lib/tox-bootstrapd ]; then
cp /etc/tox-bootstrapd.conf /var/lib/tox-bootstrapd
if [ -d /var/lib/tox-bootstrapd/Maildir ]; then
rm -rf /var/lib/tox-bootstrapd/Maildir
fi
fi
}
function backup_configuration {
echo $"Backing up ${PROJECT_NAME} configuration files"
if [ ! -d /root/tempbackupconfig ]; then
mkdir -p /root/tempbackupconfig
fi
cp -f $CONFIG_FILE /root/tempbackupconfig
cp -f $COMPLETION_FILE /root/tempbackupconfig
backup_directory_to_usb /root/tempbackupconfig config
}
function backup_admin_readme {
if [ -f /home/$ADMIN_USERNAME/README ]; then
echo $"Backing up README"
if [ ! -d /home/$ADMIN_USERNAME/tempbackup ]; then
mkdir -p /home/$ADMIN_USERNAME/tempbackup
fi
cp -f /home/$ADMIN_USERNAME/README /home/$ADMIN_USERNAME/tempbackup
backup_directory_to_usb /home/$ADMIN_USERNAME/tempbackup readme
fi
}
function backup_voip {
if [ -f /etc/mumble-server.ini ]; then
echo $"Backing up VoIP settings"
if [ ! -d /root/tempvoipbackup ]; then
mkdir -p /root/tempvoipbackup
fi
cp -f /etc/mumble-server.ini /root/tempvoipbackup
cp -f /var/lib/mumble-server/mumble-server.sqlite /root/tempvoipbackup
cp -f /etc/sipwitch.conf /root/tempvoipbackup
backup_directory_to_usb /root/tempvoipbackup voip
fi
}
function backup_mariadb {
if [ ${#DATABASE_PASSWORD} -gt 1 ]; then
if [ ! -d /root/tempmariadb ]; then
mkdir /root/tempmariadb
fi
mysqldump --password="$DATABASE_PASSWORD" mysql user > /root/tempmariadb/mysql.sql
if [ ! -s /root/tempmariadb/mysql.sql ]; then
echo $"Unable to backup mysql settings"
rm -rf /root/tempmariadb
umount $USB_MOUNT
rm -rf $USB_MOUNT
exit 8
fi
echo "$DATABASE_PASSWORD" > /root/tempmariadb/db
chmod 400 /root/tempmariadb/db
backup_directory_to_usb /root/tempmariadb mariadb
fi
}
# has the remove option been set ? # has the remove option been set ?
remove_option=$2 remove_option=$2
if [[ $1 == "remove" ]]; then if [[ $1 == "remove" ]]; then
@ -359,68 +425,12 @@ make_backup_directory
check_storage_space_remaining check_storage_space_remaining
update_domains update_domains
backup_users backup_users
prepare_directories
if [ -d /home/git/go/src/github.com/gogits ]; then
mv /home/git/gogs-repositories/*.git /home/git/gogs-repositories/$ADMIN_USERNAME
fi
if [ -d /var/lib/tox-bootstrapd ]; then
cp /etc/tox-bootstrapd.conf /var/lib/tox-bootstrapd
if [ -d /var/lib/tox-bootstrapd/Maildir ]; then
rm -rf /var/lib/tox-bootstrapd/Maildir
fi
fi
backup_directories backup_directories
backup_configuration
# configuration files backup_admin_readme
echo $"Backing up ${PROJECT_NAME} configuration files" backup_voip
if [ ! -d /root/tempbackupconfig ]; then backup_mariadb
mkdir -p /root/tempbackupconfig
fi
cp -f $CONFIG_FILE /root/tempbackupconfig
cp -f $COMPLETION_FILE /root/tempbackupconfig
backup_directory_to_usb /root/tempbackupconfig config
# Backup admin user README file
if [ -f /home/$ADMIN_USERNAME/README ]; then
echo $"Backing up README"
if [ ! -d /home/$ADMIN_USERNAME/tempbackup ]; then
mkdir -p /home/$ADMIN_USERNAME/tempbackup
fi
cp -f /home/$ADMIN_USERNAME/README /home/$ADMIN_USERNAME/tempbackup
backup_directory_to_usb /home/$ADMIN_USERNAME/tempbackup readme
fi
# Backup VoIP settings
if [ -f /etc/mumble-server.ini ]; then
echo $"Backing up VoIP settings"
if [ ! -d /root/tempvoipbackup ]; then
mkdir -p /root/tempvoipbackup
fi
cp -f /etc/mumble-server.ini /root/tempvoipbackup
cp -f /var/lib/mumble-server/mumble-server.sqlite /root/tempvoipbackup
cp -f /etc/sipwitch.conf /root/tempvoipbackup
backup_directory_to_usb /root/tempvoipbackup voip
fi
# MariaDB settings
if [ ${#DATABASE_PASSWORD} -gt 1 ]; then
if [ ! -d /root/tempmariadb ]; then
mkdir /root/tempmariadb
fi
mysqldump --password="$DATABASE_PASSWORD" mysql user > /root/tempmariadb/mysql.sql
if [ ! -s /root/tempmariadb/mysql.sql ]; then
echo $"Unable to backup mysql settings"
rm -rf /root/tempmariadb
umount $USB_MOUNT
rm -rf $USB_MOUNT
exit 8
fi
echo "$DATABASE_PASSWORD" > /root/tempmariadb/db
chmod 400 /root/tempmariadb/db
backup_directory_to_usb /root/tempmariadb mariadb
fi
unmount_drive unmount_drive
exit 0 exit 0