Backup and restore of mailpile
This commit is contained in:
parent
4d92bb5020
commit
d6400e0a04
|
@ -87,19 +87,115 @@ function upgrade_mailpile {
|
|||
}
|
||||
|
||||
function backup_local_mailpile {
|
||||
echo -n ''
|
||||
if [ ! -f /etc/systemd/system/mailpile.service ]; then
|
||||
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 {
|
||||
echo -n ''
|
||||
if [ ! -f /etc/systemd/system/mailpile.service ]; then
|
||||
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
|
||||
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 {
|
||||
echo -n ''
|
||||
if [ ! -f /etc/systemd/system/mailpile.service ]; then
|
||||
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 {
|
||||
echo -n ''
|
||||
if [ ! -f /etc/systemd/system/mailpile.service ]; then
|
||||
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 {
|
||||
|
|
Loading…
Reference in New Issue