We don't really need to backup mailpile

This commit is contained in:
Bob Mottram 2017-08-09 23:30:36 +01:00
parent 364b57a3d9
commit 6c904ee967
1 changed files with 5 additions and 104 deletions

View File

@ -13,7 +13,7 @@
# License # License
# ======= # =======
# #
# Copyright (C) 2016 Bob Mottram <bob@freedombone.net> # Copyright (C) 2016-2017 Bob Mottram <bob@freedombone.net>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
@ -110,118 +110,19 @@ function upgrade_mailpile {
} }
function backup_local_mailpile { function backup_local_mailpile {
if [ ! -f /etc/systemd/system/mailpile.service ]; then echo -n ''
return
fi
MAILPILE_DOMAIN_NAME='mailpile.local'
if grep -q "mailpile domain" $COMPLETION_FILE; then
MAILPILE_DOMAIN_NAME=$(get_completion_param "mailpile domain")
fi
source_directory=/var/www/${MAILPILE_DOMAIN_NAME}/mail/.local
if [ -d $source_directory ]; then
systemctl stop mailpile
function_check backup_directory_to_usb
backup_directory_to_usb $source_directory mailpile
systemctl start mailpile
fi
} }
function restore_local_mailpile { function restore_local_mailpile {
if [ ! -f /etc/systemd/system/mailpile.service ]; then echo -n ''
return
fi
MAILPILE_DOMAIN_NAME='mailpile.local'
if grep -q "mailpile domain" $COMPLETION_FILE; then
MAILPILE_DOMAIN_NAME=$(get_completion_param "mailpile domain")
fi
if [ $MAILPILE_DOMAIN_NAME ]; then
systemctl stop mailpile
temp_restore_dir=/root/tempmailpile
restore_directory_from_usb $temp_restore_dir mailpile
if [ -d /var/www/${MAILPILE_DOMAIN_NAME}/mail/.local ]; then
mv /var/www/${MAILPILE_DOMAIN_NAME}/mail/.local /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous
fi
temp_source_dir=$(find ${temp_restore_dir} -name ".local")
cp -r ${temp_source_dir} /var/www/${MAILPILE_DOMAIN_NAME}/mail/
if [ ! "$?" = "0" ]; then
if [ -d mv /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous ]; then
if [ -d /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous ]; then
rm -rf /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous
fi
mv /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous /var/www/${MAILPILE_DOMAIN_NAME}/mail/.local
fi
backup_unmount_drive
exit 3685
fi
rm -rf ${temp_restore_dir}
chown -R mailpile: /var/www/$MAILPILE_DOMAIN_NAME/mail/
if [ -d /etc/letsencrypt/live/${MAILPILE_DOMAIN_NAME} ]; then
ln -s /etc/letsencrypt/live/${MAILPILE_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${MAILPILE_DOMAIN_NAME}.key
ln -s /etc/letsencrypt/live/${MAILPILE_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${MAILPILE_DOMAIN_NAME}.pem
fi
systemctl start mailpile
fi
} }
function backup_remote_mailpile { function backup_remote_mailpile {
if [ ! -f /etc/systemd/system/mailpile.service ]; then echo -n ''
return
fi
MAILPILE_DOMAIN_NAME='mailpile.local'
if grep -q "mailpile domain" $COMPLETION_FILE; then
MAILPILE_DOMAIN_NAME=$(get_completion_param "mailpile domain")
fi
source_directory=/var/www/${MAILPILE_DOMAIN_NAME}/mail/.local
if [ -d $source_directory ]; then
systemctl stop mailpile
function_check backup_directory_to_usb
backup_directory_to_friend $source_directory mailpile
systemctl start mailpile
fi
} }
function restore_remote_mailpile { function restore_remote_mailpile {
if [ ! -f /etc/systemd/system/mailpile.service ]; then echo -n ''
return
fi
MAILPILE_DOMAIN_NAME='mailpile.local'
if grep -q "mailpile domain" $COMPLETION_FILE; then
MAILPILE_DOMAIN_NAME=$(get_completion_param "mailpile domain")
fi
if [ $MAILPILE_DOMAIN_NAME ]; then
systemctl stop mailpile
temp_restore_dir=/root/tempmailpile
restore_directory_from_friend $temp_restore_dir mailpile
if [ -d /var/www/${MAILPILE_DOMAIN_NAME}/mail/.local ]; then
mv /var/www/${MAILPILE_DOMAIN_NAME}/mail/.local /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous
fi
temp_source_dir=$(find ${temp_restore_dir} -name ".local")
cp -r ${temp_source_dir} /var/www/${MAILPILE_DOMAIN_NAME}/mail/
if [ ! "$?" = "0" ]; then
if [ -d mv /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous ]; then
mv /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous /var/www/${MAILPILE_DOMAIN_NAME}/mail/.local
fi
backup_unmount_drive
exit 36732
fi
rm -rf ${temp_restore_dir}
chown -R mailpile: /var/www/$MAILPILE_DOMAIN_NAME/mail/
if [ -d /etc/letsencrypt/live/${MAILPILE_DOMAIN_NAME} ]; then
ln -s /etc/letsencrypt/live/${MAILPILE_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${MAILPILE_DOMAIN_NAME}.key
ln -s /etc/letsencrypt/live/${MAILPILE_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${MAILPILE_DOMAIN_NAME}.pem
fi
systemctl start mailpile
fi
} }
function remove_mailpile { function remove_mailpile {