mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 05:45:59 +01:00
Merge branch 'stable' into p3 to pass on bug fix for backups
This commit is contained in:
@@ -4,9 +4,12 @@ import time
|
||||
from plogical.backupSchedule import backupSchedule
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
from re import match,I,M
|
||||
import signal
|
||||
from datetime import datetime
|
||||
|
||||
class backupScheduleLocal:
|
||||
localBackupPath = '/home/cyberpanel/localBackupPath'
|
||||
now = datetime.now()
|
||||
|
||||
@staticmethod
|
||||
def prepare():
|
||||
@@ -24,17 +27,22 @@ class backupScheduleLocal:
|
||||
|
||||
for virtualHost in os.listdir("/home"):
|
||||
if match(r'([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?', virtualHost, M | I):
|
||||
retValues = backupSchedule.createLocalBackup(virtualHost, backupLogPath)
|
||||
try:
|
||||
retValues = backupSchedule.createLocalBackup(virtualHost, backupLogPath)
|
||||
|
||||
if os.path.exists(backupScheduleLocal.localBackupPath):
|
||||
backupPath = retValues[1] + ".tar.gz"
|
||||
localBackupPath = '%s/%s' % (open(backupScheduleLocal.localBackupPath, 'r').read().rstrip('/'), time.strftime("%b-%d-%Y"))
|
||||
if os.path.exists(backupScheduleLocal.localBackupPath):
|
||||
backupPath = retValues[1] + ".tar.gz"
|
||||
localBackupPath = '%s/%s' % (open(backupScheduleLocal.localBackupPath, 'r').read().rstrip('/'), time.strftime("%b-%d-%Y"))
|
||||
|
||||
command = 'mkdir -p %s' % (localBackupPath)
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
command = 'mkdir -p %s' % (localBackupPath)
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
command = 'mv %s %s' % (backupPath, localBackupPath)
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
except BaseException, msg:
|
||||
backupSchedule.remoteBackupLogging(backupLogPath,
|
||||
'[ERROR] Backup failed for %s, error: %s moving on..' % (virtualHost, str(msg)))
|
||||
|
||||
command = 'mv %s %s' % (backupPath, localBackupPath)
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
|
||||
|
||||
@@ -57,5 +65,13 @@ def main():
|
||||
backupScheduleLocal.prepare()
|
||||
|
||||
|
||||
def handler(signum, frame):
|
||||
diff = datetime.now() - backupScheduleLocal.now
|
||||
logging.CyberCPLogFileWriter.writeToFile('Signal: %s, time spent: %s' % (str(signum), str(diff.total_seconds())))
|
||||
|
||||
if __name__ == "__main__":
|
||||
for i in range(1,32):
|
||||
if i == 9 or i == 19 or i == 32:
|
||||
continue
|
||||
signal.signal(i, handler)
|
||||
main()
|
||||
Reference in New Issue
Block a user