Skip to content

Commit 4fc5f53

Browse files
committed
bug fix" backup engine
1 parent f3ab3e5 commit 4fc5f53

File tree

1 file changed

+30
-26
lines changed

1 file changed

+30
-26
lines changed

plogical/backupUtilities.py

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -469,42 +469,46 @@ def BackupRoot(tempStoragePath, backupName, backupPath, metaPath=None):
469469

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

472-
emailPath = '/home/vmail/%s' % (domainName)
472+
try:
473473

474-
if os.path.exists(emailPath):
475-
copy_tree(emailPath, '%s/vmail' % (tempStoragePath))
474+
emailPath = '/home/vmail/%s' % (domainName)
476475

477-
## shutil.make_archive. Creating final package.
476+
if os.path.exists(emailPath):
477+
copy_tree(emailPath, '%s/vmail' % (tempStoragePath), preserve_symlinks=True)
478478

479-
make_archive(os.path.join(backupPath, backupName), 'gztar', tempStoragePath)
480-
rmtree(tempStoragePath)
479+
## shutil.make_archive. Creating final package.
481480

482-
###
481+
make_archive(os.path.join(backupPath, backupName), 'gztar', tempStoragePath)
482+
rmtree(tempStoragePath)
483483

484-
backupObs = Backups.objects.filter(fileName=backupName)
484+
###
485485

486-
## adding backup data to database.
486+
backupObs = Backups.objects.filter(fileName=backupName)
487487

488-
filePath = '%s/%s.tar.gz' % (backupPath, backupName)
489-
totalSize = '%sMB' % (str(int(os.path.getsize(filePath) / 1048576)))
488+
## adding backup data to database.
490489

491-
try:
492-
for items in backupObs:
493-
items.status = 1
494-
items.size = totalSize
495-
items.save()
496-
except BaseException as msg:
497-
logging.CyberCPLogFileWriter.writeToFile('%s. [backupRoot:499]' % str(msg))
498-
for items in backupObs:
499-
items.status = 1
500-
items.size = totalSize
501-
items.save()
490+
filePath = '%s/%s.tar.gz' % (backupPath, backupName)
491+
totalSize = '%sMB' % (str(int(os.path.getsize(filePath) / 1048576)))
502492

503-
command = 'chmod 600 %s' % (os.path.join(backupPath, backupName + ".tar.gz"))
504-
ProcessUtilities.executioner(command)
493+
try:
494+
for items in backupObs:
495+
items.status = 1
496+
items.size = totalSize
497+
items.save()
498+
except BaseException as msg:
499+
logging.CyberCPLogFileWriter.writeToFile('%s. [backupRoot:499]' % str(msg))
500+
for items in backupObs:
501+
items.status = 1
502+
items.size = totalSize
503+
items.save()
505504

506-
logging.CyberCPLogFileWriter.statusWriter(status, "Completed\n")
507-
os.remove(pidFile)
505+
command = 'chmod 600 %s' % (os.path.join(backupPath, backupName + ".tar.gz"))
506+
ProcessUtilities.executioner(command)
507+
508+
logging.CyberCPLogFileWriter.statusWriter(status, "Completed\n")
509+
os.remove(pidFile)
510+
except BaseException as msg:
511+
logging.CyberCPLogFileWriter.statusWriter(status, '%s. [511:BackupRoot][[5009]]\n' % str(msg))
508512

509513
@staticmethod
510514
def initiateBackup(tempStoragePath, backupName, backupPath):

0 commit comments

Comments
 (0)