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

@ -347,52 +347,42 @@ function remove_backup_directory {
fi fi
} }
# has the remove option been set ? function prepare_directories {
remove_option=$2 # Some miscellaneous preparation for backing up directories
if [[ $1 == "remove" ]]; then if [ -d /home/git/go/src/github.com/gogits ]; then
remove_option=$1
fi
mount_drive $1 $2
remove_backup_directory $remove_option
make_backup_directory
check_storage_space_remaining
update_domains
backup_users
if [ -d /home/git/go/src/github.com/gogits ]; then
mv /home/git/gogs-repositories/*.git /home/git/gogs-repositories/$ADMIN_USERNAME mv /home/git/gogs-repositories/*.git /home/git/gogs-repositories/$ADMIN_USERNAME
fi fi
if [ -d /var/lib/tox-bootstrapd ]; then if [ -d /var/lib/tox-bootstrapd ]; then
cp /etc/tox-bootstrapd.conf /var/lib/tox-bootstrapd cp /etc/tox-bootstrapd.conf /var/lib/tox-bootstrapd
if [ -d /var/lib/tox-bootstrapd/Maildir ]; then if [ -d /var/lib/tox-bootstrapd/Maildir ]; then
rm -rf /var/lib/tox-bootstrapd/Maildir rm -rf /var/lib/tox-bootstrapd/Maildir
fi fi
fi fi
}
backup_directories function backup_configuration {
echo $"Backing up ${PROJECT_NAME} configuration files"
# configuration files if [ ! -d /root/tempbackupconfig ]; then
echo $"Backing up ${PROJECT_NAME} configuration files"
if [ ! -d /root/tempbackupconfig ]; then
mkdir -p /root/tempbackupconfig mkdir -p /root/tempbackupconfig
fi fi
cp -f $CONFIG_FILE /root/tempbackupconfig cp -f $CONFIG_FILE /root/tempbackupconfig
cp -f $COMPLETION_FILE /root/tempbackupconfig cp -f $COMPLETION_FILE /root/tempbackupconfig
backup_directory_to_usb /root/tempbackupconfig config backup_directory_to_usb /root/tempbackupconfig config
}
# Backup admin user README file function backup_admin_readme {
if [ -f /home/$ADMIN_USERNAME/README ]; then if [ -f /home/$ADMIN_USERNAME/README ]; then
echo $"Backing up README" echo $"Backing up README"
if [ ! -d /home/$ADMIN_USERNAME/tempbackup ]; then if [ ! -d /home/$ADMIN_USERNAME/tempbackup ]; then
mkdir -p /home/$ADMIN_USERNAME/tempbackup mkdir -p /home/$ADMIN_USERNAME/tempbackup
fi fi
cp -f /home/$ADMIN_USERNAME/README /home/$ADMIN_USERNAME/tempbackup cp -f /home/$ADMIN_USERNAME/README /home/$ADMIN_USERNAME/tempbackup
backup_directory_to_usb /home/$ADMIN_USERNAME/tempbackup readme backup_directory_to_usb /home/$ADMIN_USERNAME/tempbackup readme
fi fi
}
# Backup VoIP settings function backup_voip {
if [ -f /etc/mumble-server.ini ]; then if [ -f /etc/mumble-server.ini ]; then
echo $"Backing up VoIP settings" echo $"Backing up VoIP settings"
if [ ! -d /root/tempvoipbackup ]; then if [ ! -d /root/tempvoipbackup ]; then
mkdir -p /root/tempvoipbackup mkdir -p /root/tempvoipbackup
@ -401,10 +391,11 @@ if [ -f /etc/mumble-server.ini ]; then
cp -f /var/lib/mumble-server/mumble-server.sqlite /root/tempvoipbackup cp -f /var/lib/mumble-server/mumble-server.sqlite /root/tempvoipbackup
cp -f /etc/sipwitch.conf /root/tempvoipbackup cp -f /etc/sipwitch.conf /root/tempvoipbackup
backup_directory_to_usb /root/tempvoipbackup voip backup_directory_to_usb /root/tempvoipbackup voip
fi fi
}
# MariaDB settings function backup_mariadb {
if [ ${#DATABASE_PASSWORD} -gt 1 ]; then if [ ${#DATABASE_PASSWORD} -gt 1 ]; then
if [ ! -d /root/tempmariadb ]; then if [ ! -d /root/tempmariadb ]; then
mkdir /root/tempmariadb mkdir /root/tempmariadb
fi fi
@ -419,8 +410,27 @@ if [ ${#DATABASE_PASSWORD} -gt 1 ]; then
echo "$DATABASE_PASSWORD" > /root/tempmariadb/db echo "$DATABASE_PASSWORD" > /root/tempmariadb/db
chmod 400 /root/tempmariadb/db chmod 400 /root/tempmariadb/db
backup_directory_to_usb /root/tempmariadb mariadb backup_directory_to_usb /root/tempmariadb mariadb
fi
}
# has the remove option been set ?
remove_option=$2
if [[ $1 == "remove" ]]; then
remove_option=$1
fi fi
mount_drive $1 $2
remove_backup_directory $remove_option
make_backup_directory
check_storage_space_remaining
update_domains
backup_users
prepare_directories
backup_directories
backup_configuration
backup_admin_readme
backup_voip
backup_mariadb
unmount_drive unmount_drive
exit 0 exit 0