Stop and restart the mail server when backing up

Otherwise mail can arrive during the process
This commit is contained in:
Bob Mottram 2016-06-08 22:20:41 +01:00
parent 282594eb09
commit 784cee0eda
2 changed files with 8 additions and 0 deletions

View File

@ -356,11 +356,15 @@ function backup_users {
# Backup email
if [ -d /home/$USERNAME/Maildir ]; then
echo $"Stopping mail server"
systemctl stop exim4
echo $"Creating an email archive for $USERNAME"
if [ ! -d /root/tempbackupemail/$USERNAME ]; then
mkdir -p /root/tempbackupemail/$USERNAME
fi
tar -czvf /root/tempbackupemail/$USERNAME/maildir.tar.gz /home/$USERNAME/Maildir
echo $"Restarting mail server"
systemctl start exim4
echo $"Backing up emails for $USERNAME"
backup_directory_to_usb /root/tempbackupemail/$USERNAME mail/$USERNAME
fi

View File

@ -283,11 +283,15 @@ function backup_users {
# email
if [ -d /home/$USERNAME/Maildir ]; then
echo $"Stopping mail server"
systemctl stop exim4
echo $"Creating an email archive"
if [ ! -d /root/backupemail/$USERNAME ]; then
mkdir -p /root/backupemail/$USERNAME
fi
tar -czvf /root/backupemail/$USERNAME/maildir.tar.gz /home/$USERNAME/Maildir
echo $"Restarting mail server"
systemctl start exim4
echo $"Backing up emails for $USERNAME"
backup_directory_to_friend /root/backupemail/$USERNAME mail/$USERNAME
fi