feature: set custom path for local backups

This commit is contained in:
Usman Nasir
2019-08-22 20:38:49 +05:00
parent e4f543d5a6
commit 61228595b2
5 changed files with 165 additions and 115 deletions

View File

@@ -2,8 +2,11 @@ import CyberCPLogFileWriter as logging
import os
import time
from backupSchedule import backupSchedule
from plogical.processUtilities import ProcessUtilities
from re import match,I,M
class backupScheduleLocal:
localBackupPath = '/home/cyberpanel/localBackupPath'
@staticmethod
def prepare():
@@ -20,7 +23,20 @@ class backupScheduleLocal:
backupSchedule.remoteBackupLogging(backupLogPath, "")
for virtualHost in os.listdir("/home"):
backupSchedule.createLocalBackup(virtualHost, backupLogPath)
if match(r'([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?', virtualHost, M | I):
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"))
command = 'mkdir -p %s' % (localBackupPath)
ProcessUtilities.normalExecutioner(command)
command = 'mv %s %s' % (backupPath, localBackupPath)
ProcessUtilities.normalExecutioner(command)
backupSchedule.remoteBackupLogging(backupLogPath, "")
backupSchedule.remoteBackupLogging(backupLogPath, "")