bug fix: in wp manager

This commit is contained in:
Usman Nasir
2022-08-16 14:15:46 +05:00
parent feb868b13b
commit bb5415a927
3 changed files with 3570 additions and 3421 deletions

View File

@@ -981,238 +981,241 @@ Automatic backup failed for %s on %s.
try: try:
allRemoteBackupsiteobj = RemoteBackupsites.objects.filter(owner=config.pk) allRemoteBackupsiteobj = RemoteBackupsites.objects.filter(owner=config.pk)
for i in allRemoteBackupsiteobj: for i in allRemoteBackupsiteobj:
backupsiteID = i.WPsites try:
wpsite = WPSites.objects.get(pk=backupsiteID) backupsiteID = i.WPsites
AdminID = wpsite.owner.admin_id wpsite = WPSites.objects.get(pk=backupsiteID)
Admin = Administrator.objects.get(pk=AdminID) AdminID = wpsite.owner.admin_id
Admin = Administrator.objects.get(pk=AdminID)
Lastrun = config.lastrun Lastrun = config.lastrun
Currenttime = float(time.time()) Currenttime = float(time.time())
if config.timeintervel == function: if config.timeintervel == function:
#al = float(Currenttime) - float(1800) #al = float(Currenttime) - float(1800)
#if float(al) >= float(Lastrun): #if float(al) >= float(Lastrun):
#if 1 == 1: #if 1 == 1:
extraArgs = {} extraArgs = {}
extraArgs['adminID'] = Admin.pk extraArgs['adminID'] = Admin.pk
extraArgs['WPid'] = wpsite.pk extraArgs['WPid'] = wpsite.pk
extraArgs['Backuptype'] = Backuptype extraArgs['Backuptype'] = Backuptype
extraArgs['BackupDestination'] = config.RemoteBackupConfig.configtype extraArgs['BackupDestination'] = config.RemoteBackupConfig.configtype
extraArgs['SFTPID'] = config.RemoteBackupConfig_id extraArgs['SFTPID'] = config.RemoteBackupConfig_id
extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999)) extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
background = ApplicationInstaller('WPCreateBackup', extraArgs) background = ApplicationInstaller('WPCreateBackup', extraArgs)
status, msg, backupID = background.WPCreateBackup() status, msg, backupID = background.WPCreateBackup()
if status == 1: if status == 1:
filename = msg filename = msg
if config.RemoteBackupConfig.configtype == "SFTP": if config.RemoteBackupConfig.configtype == "SFTP":
IncScheduler.SendTORemote(filename, config.RemoteBackupConfig_id) IncScheduler.SendTORemote(filename, config.RemoteBackupConfig_id)
command = f"rm -r {filename}" command = f"rm -r {filename}"
ProcessUtilities.executioner(command) ProcessUtilities.executioner(command)
obj = RemoteBackupSchedule.objects.get(pk=config.id) obj = RemoteBackupSchedule.objects.get(pk=config.id)
obj.lastrun = time.time() obj.lastrun = time.time()
obj.save() obj.save()
elif config.RemoteBackupConfig.configtype == "S3": elif config.RemoteBackupConfig.configtype == "S3":
IncScheduler.SendToS3Cloud(filename, config.RemoteBackupConfig_id, backupID, IncScheduler.SendToS3Cloud(filename, config.RemoteBackupConfig_id, backupID,
config.id) config.id)
command = f"rm -r {filename}" command = f"rm -r {filename}"
ProcessUtilities.executioner(command) ProcessUtilities.executioner(command)
obj = RemoteBackupSchedule.objects.get(pk=config.id) obj = RemoteBackupSchedule.objects.get(pk=config.id)
obj.lastrun = time.time() obj.lastrun = time.time()
obj.save() obj.save()
elif config.timeintervel == function: elif config.timeintervel == function:
#al = float(Currenttime) - float(3600) #al = float(Currenttime) - float(3600)
#if float(al) >= float(Lastrun): #if float(al) >= float(Lastrun):
# if 1 == 1: # if 1 == 1:
extraArgs = {} extraArgs = {}
extraArgs['adminID'] = Admin.pk extraArgs['adminID'] = Admin.pk
extraArgs['WPid'] = wpsite.pk extraArgs['WPid'] = wpsite.pk
extraArgs['Backuptype'] = Backuptype extraArgs['Backuptype'] = Backuptype
extraArgs['BackupDestination'] = config.RemoteBackupConfig.configtype extraArgs['BackupDestination'] = config.RemoteBackupConfig.configtype
extraArgs['SFTPID'] = config.RemoteBackupConfig_id extraArgs['SFTPID'] = config.RemoteBackupConfig_id
extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999)) extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
background = ApplicationInstaller('WPCreateBackup', extraArgs) background = ApplicationInstaller('WPCreateBackup', extraArgs)
status, msg, backupID = background.WPCreateBackup() status, msg, backupID = background.WPCreateBackup()
if status == 1: if status == 1:
filename = msg filename = msg
if config.RemoteBackupConfig.configtype == "SFTP": if config.RemoteBackupConfig.configtype == "SFTP":
IncScheduler.SendTORemote(filename, config.RemoteBackupConfig_id) IncScheduler.SendTORemote(filename, config.RemoteBackupConfig_id)
command = f"rm -r {filename}" command = f"rm -r {filename}"
ProcessUtilities.executioner(command) ProcessUtilities.executioner(command)
obj = RemoteBackupSchedule.objects.get(pk=config.id) obj = RemoteBackupSchedule.objects.get(pk=config.id)
obj.lastrun = time.time() obj.lastrun = time.time()
obj.save() obj.save()
elif config.RemoteBackupConfig.configtype == "S3": elif config.RemoteBackupConfig.configtype == "S3":
IncScheduler.SendToS3Cloud(filename, config.RemoteBackupConfig_id, backupID, IncScheduler.SendToS3Cloud(filename, config.RemoteBackupConfig_id, backupID,
config.id) config.id)
command = f"rm -r {filename}" command = f"rm -r {filename}"
ProcessUtilities.executioner(command) ProcessUtilities.executioner(command)
obj = RemoteBackupSchedule.objects.get(pk=config.id) obj = RemoteBackupSchedule.objects.get(pk=config.id)
obj.lastrun = time.time() obj.lastrun = time.time()
obj.save() obj.save()
elif config.timeintervel == function: elif config.timeintervel == function:
#al = float(Currenttime) - float(21600) #al = float(Currenttime) - float(21600)
#if float(al) >= float(Lastrun): #if float(al) >= float(Lastrun):
extraArgs = {} extraArgs = {}
extraArgs['adminID'] = Admin.pk extraArgs['adminID'] = Admin.pk
extraArgs['WPid'] = wpsite.pk extraArgs['WPid'] = wpsite.pk
extraArgs['Backuptype'] = Backuptype extraArgs['Backuptype'] = Backuptype
extraArgs['BackupDestination'] = "SFTP" extraArgs['BackupDestination'] = "SFTP"
extraArgs['SFTPID'] = config.RemoteBackupConfig_id extraArgs['SFTPID'] = config.RemoteBackupConfig_id
extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999)) extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
background = ApplicationInstaller('WPCreateBackup', extraArgs) background = ApplicationInstaller('WPCreateBackup', extraArgs)
status, msg, backupID = background.WPCreateBackup() status, msg, backupID = background.WPCreateBackup()
if status == 1: if status == 1:
filename = msg filename = msg
if config.RemoteBackupConfig.configtype == "SFTP": if config.RemoteBackupConfig.configtype == "SFTP":
IncScheduler.SendTORemote(filename, config.RemoteBackupConfig_id) IncScheduler.SendTORemote(filename, config.RemoteBackupConfig_id)
command = f"rm -r {filename}" command = f"rm -r {filename}"
ProcessUtilities.executioner(command) ProcessUtilities.executioner(command)
obj = RemoteBackupSchedule.objects.get(pk=config.id) obj = RemoteBackupSchedule.objects.get(pk=config.id)
obj.lastrun = time.time() obj.lastrun = time.time()
obj.save() obj.save()
elif config.RemoteBackupConfig.configtype == "S3": elif config.RemoteBackupConfig.configtype == "S3":
IncScheduler.SendToS3Cloud(filename, config.RemoteBackupConfig_id, backupID, IncScheduler.SendToS3Cloud(filename, config.RemoteBackupConfig_id, backupID,
config.id) config.id)
command = f"rm -r {filename}" command = f"rm -r {filename}"
ProcessUtilities.executioner(command) ProcessUtilities.executioner(command)
obj = RemoteBackupSchedule.objects.get(pk=config.id) obj = RemoteBackupSchedule.objects.get(pk=config.id)
obj.lastrun = time.time() obj.lastrun = time.time()
obj.save() obj.save()
elif config.timeintervel == function: elif config.timeintervel == function:
#al = float(Currenttime) - float(43200) #al = float(Currenttime) - float(43200)
#if float(al) >= float(Lastrun): #if float(al) >= float(Lastrun):
extraArgs = {} extraArgs = {}
extraArgs['adminID'] = Admin.pk extraArgs['adminID'] = Admin.pk
extraArgs['WPid'] = wpsite.pk extraArgs['WPid'] = wpsite.pk
extraArgs['Backuptype'] = Backuptype extraArgs['Backuptype'] = Backuptype
extraArgs['BackupDestination'] = "SFTP" extraArgs['BackupDestination'] = "SFTP"
extraArgs['SFTPID'] = config.RemoteBackupConfig_id extraArgs['SFTPID'] = config.RemoteBackupConfig_id
extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999)) extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
background = ApplicationInstaller('WPCreateBackup', extraArgs) background = ApplicationInstaller('WPCreateBackup', extraArgs)
status, msg, backupID = background.WPCreateBackup() status, msg, backupID = background.WPCreateBackup()
if status == 1: if status == 1:
filename = msg filename = msg
if config.RemoteBackupConfig.configtype == "SFTP": if config.RemoteBackupConfig.configtype == "SFTP":
IncScheduler.SendTORemote(filename, config.RemoteBackupConfig_id) IncScheduler.SendTORemote(filename, config.RemoteBackupConfig_id)
command = f"rm -r {filename}" command = f"rm -r {filename}"
ProcessUtilities.executioner(command) ProcessUtilities.executioner(command)
obj = RemoteBackupSchedule.objects.get(pk=config.id) obj = RemoteBackupSchedule.objects.get(pk=config.id)
obj.lastrun = time.time() obj.lastrun = time.time()
obj.save() obj.save()
elif config.RemoteBackupConfig.configtype == "S3": elif config.RemoteBackupConfig.configtype == "S3":
IncScheduler.SendToS3Cloud(filename, config.RemoteBackupConfig_id, backupID, IncScheduler.SendToS3Cloud(filename, config.RemoteBackupConfig_id, backupID,
config.id) config.id)
command = f"rm -r {filename}" command = f"rm -r {filename}"
ProcessUtilities.executioner(command) ProcessUtilities.executioner(command)
obj = RemoteBackupSchedule.objects.get(pk=config.id) obj = RemoteBackupSchedule.objects.get(pk=config.id)
obj.lastrun = time.time() obj.lastrun = time.time()
obj.save() obj.save()
elif config.timeintervel == function: elif config.timeintervel == function:
#al = float(Currenttime) - float(86400) #al = float(Currenttime) - float(86400)
#if float(al) >= float(Lastrun): #if float(al) >= float(Lastrun):
extraArgs = {} extraArgs = {}
extraArgs['adminID'] = Admin.pk extraArgs['adminID'] = Admin.pk
extraArgs['WPid'] = wpsite.pk extraArgs['WPid'] = wpsite.pk
extraArgs['Backuptype'] = Backuptype extraArgs['Backuptype'] = Backuptype
extraArgs['BackupDestination'] = "SFTP" extraArgs['BackupDestination'] = "SFTP"
extraArgs['SFTPID'] = config.RemoteBackupConfig_id extraArgs['SFTPID'] = config.RemoteBackupConfig_id
extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999)) extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
background = ApplicationInstaller('WPCreateBackup', extraArgs) background = ApplicationInstaller('WPCreateBackup', extraArgs)
status, msg, backupID = background.WPCreateBackup() status, msg, backupID = background.WPCreateBackup()
if status == 1: if status == 1:
filename = msg filename = msg
if config.RemoteBackupConfig.configtype == "SFTP": if config.RemoteBackupConfig.configtype == "SFTP":
IncScheduler.SendTORemote(filename, config.RemoteBackupConfig_id) IncScheduler.SendTORemote(filename, config.RemoteBackupConfig_id)
command = f"rm -r {filename}" command = f"rm -r {filename}"
ProcessUtilities.executioner(command) ProcessUtilities.executioner(command)
obj = RemoteBackupSchedule.objects.get(pk=config.id) obj = RemoteBackupSchedule.objects.get(pk=config.id)
obj.lastrun = time.time() obj.lastrun = time.time()
obj.save() obj.save()
elif config.RemoteBackupConfig.configtype == "S3": elif config.RemoteBackupConfig.configtype == "S3":
IncScheduler.SendToS3Cloud(filename, config.RemoteBackupConfig_id, backupID, IncScheduler.SendToS3Cloud(filename, config.RemoteBackupConfig_id, backupID,
config.id) config.id)
command = f"rm -r {filename}" command = f"rm -r {filename}"
ProcessUtilities.executioner(command) ProcessUtilities.executioner(command)
obj = RemoteBackupSchedule.objects.get(pk=config.id) obj = RemoteBackupSchedule.objects.get(pk=config.id)
obj.lastrun = time.time() obj.lastrun = time.time()
obj.save() obj.save()
elif config.timeintervel == function: elif config.timeintervel == function:
#al = float(Currenttime) - float(259200) #al = float(Currenttime) - float(259200)
#if float(al) >= float(Lastrun): #if float(al) >= float(Lastrun):
extraArgs = {} extraArgs = {}
extraArgs['adminID'] = Admin.pk extraArgs['adminID'] = Admin.pk
extraArgs['WPid'] = wpsite.pk extraArgs['WPid'] = wpsite.pk
extraArgs['Backuptype'] = Backuptype extraArgs['Backuptype'] = Backuptype
extraArgs['BackupDestination'] = "SFTP" extraArgs['BackupDestination'] = "SFTP"
extraArgs['SFTPID'] = config.RemoteBackupConfig_id extraArgs['SFTPID'] = config.RemoteBackupConfig_id
extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999)) extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
background = ApplicationInstaller('WPCreateBackup', extraArgs) background = ApplicationInstaller('WPCreateBackup', extraArgs)
status, msg, backupID = background.WPCreateBackup() status, msg, backupID = background.WPCreateBackup()
if status == 1: if status == 1:
filename = msg filename = msg
if config.RemoteBackupConfig.configtype == "SFTP": if config.RemoteBackupConfig.configtype == "SFTP":
IncScheduler.SendTORemote(filename, config.RemoteBackupConfig_id) IncScheduler.SendTORemote(filename, config.RemoteBackupConfig_id)
command = f"rm -r {filename}" command = f"rm -r {filename}"
ProcessUtilities.executioner(command) ProcessUtilities.executioner(command)
obj = RemoteBackupSchedule.objects.get(pk=config.id) obj = RemoteBackupSchedule.objects.get(pk=config.id)
obj.lastrun = time.time() obj.lastrun = time.time()
obj.save() obj.save()
elif config.RemoteBackupConfig.configtype == "S3": elif config.RemoteBackupConfig.configtype == "S3":
IncScheduler.SendToS3Cloud(filename, config.RemoteBackupConfig_id, backupID, IncScheduler.SendToS3Cloud(filename, config.RemoteBackupConfig_id, backupID,
config.id) config.id)
command = f"rm -r {filename}" command = f"rm -r {filename}"
ProcessUtilities.executioner(command) ProcessUtilities.executioner(command)
obj = RemoteBackupSchedule.objects.get(pk=config.id) obj = RemoteBackupSchedule.objects.get(pk=config.id)
obj.lastrun = time.time() obj.lastrun = time.time()
obj.save() obj.save()
elif config.timeintervel == function: elif config.timeintervel == function:
#al = float(Currenttime) - float(604800) #al = float(Currenttime) - float(604800)
#if float(al) >= float(Lastrun): #if float(al) >= float(Lastrun):
extraArgs = {} extraArgs = {}
extraArgs['adminID'] = Admin.pk extraArgs['adminID'] = Admin.pk
extraArgs['WPid'] = wpsite.pk extraArgs['WPid'] = wpsite.pk
extraArgs['Backuptype'] = Backuptype extraArgs['Backuptype'] = Backuptype
extraArgs['BackupDestination'] = "SFTP" extraArgs['BackupDestination'] = "SFTP"
extraArgs['SFTPID'] = config.RemoteBackupConfig_id extraArgs['SFTPID'] = config.RemoteBackupConfig_id
extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999)) extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
background = ApplicationInstaller('WPCreateBackup', extraArgs) background = ApplicationInstaller('WPCreateBackup', extraArgs)
status, msg, backupID = background.WPCreateBackup() status, msg, backupID = background.WPCreateBackup()
if status == 1: if status == 1:
filename = msg filename = msg
if config.RemoteBackupConfig.configtype == "SFTP": if config.RemoteBackupConfig.configtype == "SFTP":
IncScheduler.SendTORemote(filename, config.RemoteBackupConfig_id) IncScheduler.SendTORemote(filename, config.RemoteBackupConfig_id)
command = f"rm -r {filename}" command = f"rm -r {filename}"
ProcessUtilities.executioner(command) ProcessUtilities.executioner(command)
obj = RemoteBackupSchedule.objects.get(pk=config.id) obj = RemoteBackupSchedule.objects.get(pk=config.id)
obj.lastrun = time.time() obj.lastrun = time.time()
obj.save() obj.save()
elif config.RemoteBackupConfig.configtype == "S3": elif config.RemoteBackupConfig.configtype == "S3":
IncScheduler.SendToS3Cloud(filename, config.RemoteBackupConfig_id, backupID, IncScheduler.SendToS3Cloud(filename, config.RemoteBackupConfig_id, backupID,
config.id) config.id)
command = f"rm -r {filename}" command = f"rm -r {filename}"
ProcessUtilities.executioner(command) ProcessUtilities.executioner(command)
obj = RemoteBackupSchedule.objects.get(pk=config.id) obj = RemoteBackupSchedule.objects.get(pk=config.id)
obj.lastrun = time.time() obj.lastrun = time.time()
obj.save() obj.save()
except:
pass
except BaseException as msg: except BaseException as msg:
print("Error in Sites:%s" % str(msg)) print("Error in Sites:%s" % str(msg))

File diff suppressed because it is too large Load Diff

View File

@@ -311,11 +311,14 @@ class WebsiteManager:
allRemoteBackupsites = RemoteBackupsites.objects.filter(owner=RemoteBackupScheduleobj) allRemoteBackupsites = RemoteBackupsites.objects.filter(owner=RemoteBackupScheduleobj)
Data['RemoteBackupsites'] = [] Data['RemoteBackupsites'] = []
for i in allRemoteBackupsites: for i in allRemoteBackupsites:
wpsite = WPSites.objects.get(pk=i.WPsites) try:
Data['RemoteBackupsites'].append({ wpsite = WPSites.objects.get(pk=i.WPsites)
'id': i.pk, Data['RemoteBackupsites'].append({
'Title': wpsite.title, 'id': i.pk,
}) 'Title': wpsite.title,
})
except:
pass
proc = httpProc(request, 'websiteFunctions/AddRemoteBackupSite.html', proc = httpProc(request, 'websiteFunctions/AddRemoteBackupSite.html',
Data, 'createWebsite') Data, 'createWebsite')
return proc.render() return proc.render()