2121
2222class backupScheduleLocal :
2323 localBackupPath = '/home/cyberpanel/localBackupPath'
24+ runningPath = '/home/cyberpanel/localBackupPID'
2425 now = datetime .now ()
2526
2627 @staticmethod
2728 def prepare ():
2829 try :
30+
31+ if os .path .exists (backupScheduleLocal .runningPath ):
32+ pid = open (backupScheduleLocal .runningPath , 'r' ).read ()
33+ print ('Local backup is already running with PID: %s. If you want to run againly kindly kill the backup process: \n \n kill -9 %s.\n \n ' % (pid , pid ))
34+ return 0
35+
36+ writeToFile = open (backupScheduleLocal .runningPath , 'w' )
37+ writeToFile .write (str (os .getpid ()))
38+ writeToFile .close ()
39+
2940 backupRunTime = time .strftime ("%m.%d.%Y_%H-%M-%S" )
3041 backupLogPath = "/usr/local/lscp/logs/local_backup_log." + backupRunTime
3142
@@ -70,8 +81,6 @@ def prepare():
7081 backupSchedule .remoteBackupLogging (backupLogPath ,
7182 '[ERROR] Backup failed for %s, error: %s moving on..' % (virtualHost , str (msg )), backupSchedule .ERROR )
7283
73-
74-
7584 backupSchedule .remoteBackupLogging (backupLogPath , "" )
7685 backupSchedule .remoteBackupLogging (backupLogPath , "" )
7786
@@ -89,6 +98,9 @@ def prepare():
8998 job .jobSuccessSites = jobSuccessSites
9099 job .save ()
91100
101+ if os .path .exists (backupScheduleLocal .runningPath ):
102+ os .remove (backupScheduleLocal .runningPath )
103+
92104 except BaseException as msg :
93105 logging .CyberCPLogFileWriter .writeToFile (str (msg ) + " [214:startBackup]" )
94106
0 commit comments