Backup and restore blocklist

This commit is contained in:
Bob Mottram 2017-06-26 11:08:38 +01:00
parent 7daf077ee1
commit 7a222289d0
5 changed files with 85 additions and 4 deletions

View File

@ -259,6 +259,22 @@ function prepare_directories {
fi
}
function backup_blocklist {
if [ ! -f /root/${PROJECT_NAME}-firewall-domains.cfg ]; then
return
fi
echo $"Backing up ${PROJECT_NAME} blocklist"
temp_backup_dir=/root/tempbackupblocklist
if [ ! -d $temp_backup_dir ]; then
mkdir -p $temp_backup_dir
fi
if [ -f $NODEJS_INSTALLED_APPS_FILE ]; then
cp -f /root/${PROJECT_NAME}-firewall-domains.cfg $temp_backup_dir
fi
backup_directory_to_usb $temp_backup_dir blocklist
rm -rf $temp_backup_dir
}
function backup_configfiles {
echo $"Backing up ${PROJECT_NAME} configuration files"
temp_backup_dir=/root/tempbackupconfig
@ -285,6 +301,7 @@ function backup_configfiles {
cp -f /etc/nginx/.htpasswd $temp_backup_dir/htpasswd
fi
backup_directory_to_usb $temp_backup_dir configfiles
rm -rf $temp_backup_dir
}
function backup_admin_readme {
@ -335,6 +352,7 @@ prepare_directories
backup_directories
backup_apps local
backup_configfiles
backup_blocklist
backup_admin_readme
backup_mariadb
backup_extra_directories local

View File

@ -105,6 +105,22 @@ function restart_site {
SUSPENDED_SITE=
}
function backup_blocklist {
if [ ! -f /root/${PROJECT_NAME}-firewall-domains.cfg ]; then
return
fi
echo $"Backing up ${PROJECT_NAME} blocklist"
temp_backup_dir=/root/tempbackupblocklist
if [ ! -d $temp_backup_dir ]; then
mkdir -p $temp_backup_dir
fi
if [ -f $NODEJS_INSTALLED_APPS_FILE ]; then
cp -f /root/${PROJECT_NAME}-firewall-domains.cfg $temp_backup_dir
fi
backup_directory_to_friend $temp_backup_dir blocklist
rm -rf $temp_backup_dir
}
function backup_configfiles {
echo $"Backing up ${PROJECT_NAME} configuration files"
temp_backup_dir=/root/tempbackupconfig
@ -386,6 +402,7 @@ fi
backup_configfiles
if [[ $TEST_MODE == "no" ]]; then
backup_blocklist
backup_users
backup_letsencrypt
backup_passwordstore

View File

@ -1102,6 +1102,7 @@ function restore_data_from_storage {
fi
utils_installed=(configfiles
blocklist
mariadb
letsencrypt
passwords

View File

@ -111,6 +111,27 @@ function copy_gpg_keys {
gpg_set_permissions root
}
function restore_blocklist {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'blocklist' ]]; then
return
fi
fi
# this restores *.cfg and COMPLETION_FILE
if [ -d $USB_MOUNT/backup/blocklist ]; then
echo $"Restoring blocklist"
temp_restore_dir=/root/tempblocklist
restore_directory_from_usb $temp_restore_dir blocklist
if [ -f $temp_restore_dir/root/tempbackupblocklist/${PROJECT_NAME}-firewall-domains.cfg ]; then
cp -f $temp_restore_dir/root/tempbackupblocklist/${PROJECT_NAME}-firewall-domains.cfg /root/${PROJECT_NAME}-firewall-domains.cfg
fi
rm -rf $temp_restore_dir
fi
}
function restore_configfiles {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'configfiles' ]]; then
@ -119,9 +140,9 @@ function restore_configfiles {
fi
# this restores *.cfg and COMPLETION_FILE
if [ -d $USB_MOUNT/backup/config ]; then
if [ -d $USB_MOUNT/backup/configfiles ]; then
echo $"Restoring configuration files"
temp_restore_dir=/root/tempconfig
temp_restore_dir=/root/tempconfigfiles
restore_directory_from_usb $temp_restore_dir configfiles
if [ -f $temp_restore_dir/root/.nostore ]; then
@ -741,6 +762,7 @@ backup_mount_drive ${1} ${ADMIN_USERNAME} ${2}
check_backup_exists
check_admin_user
copy_gpg_keys
restore_blocklist
restore_configfiles
same_admin_user
restore_passwordstore

View File

@ -102,15 +102,37 @@ function copy_gpg_keys {
gpg_set_permissions root
}
function restore_blocklist {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'blocklist' ]]; then
return
fi
fi
# this restores *.cfg and COMPLETION_FILE
if [ -d $USB_MOUNT/backup/blocklist ]; then
echo $"Restoring blocklist"
temp_restore_dir=/root/tempblocklist
restore_directory_from_friend $temp_restore_dir blocklist
restore_directory_from_usb $temp_restore_dir blocklist
if [ -f $temp_restore_dir/root/tempbackupblocklist/${PROJECT_NAME}-firewall-domains.cfg ]; then
cp -f $temp_restore_dir/root/tempbackupblocklist/${PROJECT_NAME}-firewall-domains.cfg /root/${PROJECT_NAME}-firewall-domains.cfg
fi
rm -rf $temp_restore_dir
fi
}
function restore_configfiles {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'configfiles' ]]; then
return
fi
fi
if [ -d $SERVER_DIRECTORY/backup/config ]; then
if [ -d $SERVER_DIRECTORY/backup/configfiles ]; then
echo $"Restoring configuration files"
temp_restore_dir=/root/tempconfig
temp_restore_dir=/root/tempconfigfiles
restore_directory_from_friend $temp_restore_dir configfiles
if [ -f $temp_restore_dir/root/.nostore ]; then
@ -655,6 +677,7 @@ function restore_email {
${PROJECT_NAME}-recoverkey -u ${ADMIN_USERNAME} -l $BACKUP_LIST
copy_gpg_keys
restore_blocklist
restore_configfiles
restore_passwordstore
restore_mariadb