Skip to content

Commit

Permalink
feature: remove duplicatte compression for emails
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Apr 7, 2020
1 parent 28c3dfc commit 585a063
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions plogical/backupUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,11 +471,10 @@ def BackupRoot(tempStoragePath, backupName, backupPath, metaPath=None):

logging.CyberCPLogFileWriter.statusWriter(status, "Backing up email accounts..\n")

try:
make_archive(os.path.join(tempStoragePath, domainName), 'gztar', os.path.join("/home", "vmail", domainName))
except BaseException as msg:
pass
emailPath = '/home/vmail/%s' % (domainName)

if os.path.exists(emailPath):
copy_tree(emailPath, '%s/vmail' % (tempStoragePath))

## shutil.make_archive. Creating final package.

Expand Down Expand Up @@ -862,21 +861,32 @@ def startRestore(backupName, dir):

logging.CyberCPLogFileWriter.statusWriter(status, "Extracting email accounts!")

try:
pathToCompressedEmails = os.path.join(completPath, masterDomain + ".tar.gz")
emailHome = os.path.join("/home","vmail",masterDomain)
if not twoPointO:

tar = tarfile.open(pathToCompressedEmails)
tar.extractall(emailHome)
tar.close()
try:
pathToCompressedEmails = os.path.join(completPath, masterDomain + ".tar.gz")
emailHome = os.path.join("/home","vmail",masterDomain)

## Change permissions
tar = tarfile.open(pathToCompressedEmails)
tar.extractall(emailHome)
tar.close()

command = "chmod -r vmail:vmail " + emailHome
subprocess.call(shlex.split(command))
## Change permissions

except:
pass
command = "chown -R vmail:vmail " + emailHome
subprocess.call(shlex.split(command))

except:
pass
else:

emailsPath = '%s/vmail' % (completPath)

if os.path.exists(emailsPath):
copy_tree(emailsPath, '/home/vmail/%s' % (masterDomain))

command = "chown -R vmail:vmail /home/vmail/%s" % (masterDomain)
ProcessUtilities.executioner(command)

## emails extracted

Expand Down

0 comments on commit 585a063

Please sign in to comment.