fixed mail backup/restore

This commit is contained in:
Spitap
2022-07-27 15:51:22 +02:00
parent ee2ccf0647
commit 563979a7dd
2 changed files with 7 additions and 3 deletions

View File

@@ -31,7 +31,7 @@ class Backup():
def __init__(self, config, bashArg, nomail):
self.config = config
self.destinationPath = ""
self.BACKUPDIRECTORY = ["mails/", "custom/", "databases/"]
self.BACKUPDIRECTORY = ["custom/", "databases/"]
self.nomail = nomail
self.isBash = False
self.bash = ""
@@ -126,7 +126,7 @@ class Backup():
f" ({home_path}) seems not right...", utils.RED)
else:
dst = self.destinationPath + self.BACKUPDIRECTORY[0] + "vmail/"
dst = self.destinationPath + "mails/"
if os.path.exists(dst):
shutil.rmtree(dst)

View File

@@ -90,7 +90,11 @@ class Dovecot(base.Installer):
"""Additional tasks."""
if self.restore and len(os.listdir(self.restore + "mails")) > 0:
utils.printcolor("Copying mail backup over dovecot directory", utils.MAGENTA)
shutil.copytree(self.restore+"mails/vmails", self.home_dir, dirs_exist_ok=True)
if os.path.exists(self.home_dir):
shutil.rmtree(self.home_dir)
shutil.copytree(self.restore+"mails/", self.home_dir)
elif self.restore:
utils.printcolor("It seems that mails were not backed up, skipping mail restoration.", utils.MAGENTA)