Skip to content
Permalink
Browse files
bug fix" backup engine
  • Loading branch information
usmannasir committed Jun 10, 2020
1 parent f3ab3e5 commit 4fc5f53693f274fabde9d902a7187677c9b97a25
Showing 1 changed file with 30 additions and 26 deletions.
@@ -469,42 +469,46 @@ def BackupRoot(tempStoragePath, backupName, backupPath, metaPath=None):

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

emailPath = '/home/vmail/%s' % (domainName)
try:

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

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

make_archive(os.path.join(backupPath, backupName), 'gztar', tempStoragePath)
rmtree(tempStoragePath)
## shutil.make_archive. Creating final package.

###
make_archive(os.path.join(backupPath, backupName), 'gztar', tempStoragePath)
rmtree(tempStoragePath)

backupObs = Backups.objects.filter(fileName=backupName)
###

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

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

try:
for items in backupObs:
items.status = 1
items.size = totalSize
items.save()
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile('%s. [backupRoot:499]' % str(msg))
for items in backupObs:
items.status = 1
items.size = totalSize
items.save()
filePath = '%s/%s.tar.gz' % (backupPath, backupName)
totalSize = '%sMB' % (str(int(os.path.getsize(filePath) / 1048576)))

command = 'chmod 600 %s' % (os.path.join(backupPath, backupName + ".tar.gz"))
ProcessUtilities.executioner(command)
try:
for items in backupObs:
items.status = 1
items.size = totalSize
items.save()
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile('%s. [backupRoot:499]' % str(msg))
for items in backupObs:
items.status = 1
items.size = totalSize
items.save()

logging.CyberCPLogFileWriter.statusWriter(status, "Completed\n")
os.remove(pidFile)
command = 'chmod 600 %s' % (os.path.join(backupPath, backupName + ".tar.gz"))
ProcessUtilities.executioner(command)

logging.CyberCPLogFileWriter.statusWriter(status, "Completed\n")
os.remove(pidFile)
except BaseException as msg:
logging.CyberCPLogFileWriter.statusWriter(status, '%s. [511:BackupRoot][[5009]]\n' % str(msg))

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

0 comments on commit 4fc5f53

Please sign in to comment.