Skip to content

Commit

Permalink
bug fix: backup schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Aug 26, 2019
1 parent af182ad commit 35031cb
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions backup/backupManager.py
Expand Up @@ -655,13 +655,13 @@ def submitBackupSchedule(self, userID = None, data = None):
return HttpResponse(final_json)
else:
if backupDest == "Home" and backupFreq == "Daily":
cronJob = "0 3 * * * root python /usr/local/CyberCP/plogical/backupScheduleLocal.py"
cronJob = "0 3 * * * root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/plogical/backupScheduleLocal.py"
elif backupDest == "Home" and backupFreq == "Weekly":
cronJob = "0 0 * * 0 root python /usr/local/CyberCP/plogical/backupScheduleLocal.py "
cronJob = "0 0 * * 0 root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/plogical/backupScheduleLocal.py "
elif backupDest != "Home" and backupFreq == "Daily":
cronJob = "0 3 * * * root python /usr/local/CyberCP/plogical/backupSchedule.py"
cronJob = "0 3 * * * root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/plogical/backupSchedule.py"
elif backupDest != "Home" and backupFreq == "Weekly":
cronJob = "0 0 * * 0 root python /usr/local/CyberCP/plogical/backupSchedule.py "
cronJob = "0 0 * * 0 root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/plogical/backupSchedule.py "

command = "cat " + path
output = ProcessUtilities.outputExecutioner(command)
Expand All @@ -684,9 +684,10 @@ def submitBackupSchedule(self, userID = None, data = None):

## Set local path for backup

writeToFile = open(BackupManager.localBackupPath, 'w')
writeToFile.write(data['localPath'])
writeToFile.close()
if backupDest == "Home":
writeToFile = open(BackupManager.localBackupPath, 'w')
writeToFile.write(data['localPath'])
writeToFile.close()

destination = dest.objects.get(destLoc=backupDest)
newSchedule = backupSchedules(dest=destination, frequency=backupFreq)
Expand All @@ -696,13 +697,13 @@ def submitBackupSchedule(self, userID = None, data = None):
return HttpResponse(final_json)
except:
if backupDest == "Home" and backupFreq == "Daily":
cronJob = "0 3 * * * root python /usr/local/CyberCP/plogical/backupScheduleLocal.py"
cronJob = "0 3 * * * root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/plogical/backupScheduleLocal.py"
elif backupDest == "Home" and backupFreq == "Weekly":
cronJob = "0 0 * * 0 root python /usr/local/CyberCP/plogical/backupScheduleLocal.py "
cronJob = "0 0 * * 0 root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/plogical/backupScheduleLocal.py "
elif backupDest != "Home" and backupFreq == "Daily":
cronJob = "0 3 * * * root python /usr/local/CyberCP/plogical/backupSchedule.py"
cronJob = "0 3 * * * root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/plogical/backupSchedule.py"
elif backupDest != "Home" and backupFreq == "Weekly":
cronJob = "0 0 * * 0 root python /usr/local/CyberCP/plogical/backupSchedule.py "
cronJob = "0 0 * * 0 root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/plogical/backupSchedule.py "

command = "cat " + path
output = ProcessUtilities.outputExecutioner(command)
Expand All @@ -729,9 +730,10 @@ def submitBackupSchedule(self, userID = None, data = None):

## Set local path for backup

writeToFile = open(BackupManager.localBackupPath, 'w')
writeToFile.write(data['localPath'])
writeToFile.close()
if backupDest == "Home":
writeToFile = open(BackupManager.localBackupPath, 'w')
writeToFile.write(data['localPath'])
writeToFile.close()

final_json = json.dumps({'scheduleStatus': 1, 'error_message': "None"})
return HttpResponse(final_json)
Expand Down

0 comments on commit 35031cb

Please sign in to comment.