From d297fa6bdb20260d2ef15ec7c0bf43124ffd5329 Mon Sep 17 00:00:00 2001 From: Hassan Hashmi <75794688+habbi-hb@users.noreply.github.com> Date: Mon, 27 Jun 2022 16:58:37 +0500 Subject: [PATCH] remotebackupdone --- plogical/IncScheduler.py | 38 ++++++++++++++++++- plogical/applicationInstaller.py | 7 ++++ .../websiteFunctions/RestoreBackups.html | 5 +++ websiteFunctions/website.py | 4 +- 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/plogical/IncScheduler.py b/plogical/IncScheduler.py index 724ec186e..4f1219645 100644 --- a/plogical/IncScheduler.py +++ b/plogical/IncScheduler.py @@ -991,6 +991,8 @@ Automatic backup failed for %s on %s. extraArgs['adminID'] = Admin.pk extraArgs['WPid'] = wpsite.pk extraArgs['Backuptype'] = Backuptype + extraArgs['BackupDestination'] = "SFTP" + extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999)) Lastrun = config.lastrun Currenttime = float(time.time()) @@ -1003,6 +1005,11 @@ Automatic backup failed for %s on %s. if status == 1: filename = msg IncScheduler.SendTORemote(filename, config.RemoteBackupConfig_id) + command = f"rm -r {filename}" + ProcessUtilities.executioner(command) + obj = RemoteBackupSchedule.objects.get(pk=config.id) + obj.lastrun = time.time() + obj.save() elif config.timeintervel == "1 Hour": al = float(Currenttime) - float(3600) if float(al) >= float(Lastrun): @@ -1011,6 +1018,11 @@ Automatic backup failed for %s on %s. if status == 1: filename = msg IncScheduler.SendTORemote(filename, config.RemoteBackupConfig_id) + command = f"rm -r {filename}" + ProcessUtilities.executioner(command) + obj = RemoteBackupSchedule.objects.get(pk=config.id) + obj.lastrun = time.time() + obj.save() elif config.timeintervel == "6 Hours": al = float(Currenttime) - float(21600) if float(al) >= float(Lastrun): @@ -1019,6 +1031,11 @@ Automatic backup failed for %s on %s. if status == 1: filename = msg IncScheduler.SendTORemote(filename, config.RemoteBackupConfig_id) + command = f"rm -r {filename}" + ProcessUtilities.executioner(command) + obj = RemoteBackupSchedule.objects.get(pk=config.id) + obj.lastrun = time.time() + obj.save() elif config.timeintervel == "12 Hours": al = float(Currenttime) - float(43200) if float(al) >= float(Lastrun): @@ -1027,6 +1044,11 @@ Automatic backup failed for %s on %s. if status == 1: filename = msg IncScheduler.SendTORemote(filename, config.RemoteBackupConfig_id) + command = f"rm -r {filename}" + ProcessUtilities.executioner(command) + obj = RemoteBackupSchedule.objects.get(pk=config.id) + obj.lastrun = time.time() + obj.save() elif config.timeintervel == "1 Day": al = float(Currenttime) - float(86400) if float(al) >= float(Lastrun): @@ -1035,6 +1057,11 @@ Automatic backup failed for %s on %s. if status == 1: filename = msg IncScheduler.SendTORemote(filename, config.RemoteBackupConfig_id) + command = f"rm -r {filename}" + ProcessUtilities.executioner(command) + obj = RemoteBackupSchedule.objects.get(pk=config.id) + obj.lastrun = time.time() + obj.save() elif config.timeintervel == "3 Days": al = float(Currenttime) - float(259200) if float(al) >= float(Lastrun): @@ -1043,6 +1070,11 @@ Automatic backup failed for %s on %s. if status == 1: filename = msg IncScheduler.SendTORemote(filename, config.RemoteBackupConfig_id) + command = f"rm -r {filename}" + ProcessUtilities.executioner(command) + obj = RemoteBackupSchedule.objects.get(pk=config.id) + obj.lastrun = time.time() + obj.save() elif config.timeintervel == "1 Week": al = float(Currenttime) - float(604800) if float(al) >= float(Lastrun): @@ -1051,8 +1083,12 @@ Automatic backup failed for %s on %s. if status == 1: filename = msg IncScheduler.SendTORemote(filename, config.RemoteBackupConfig_id) + command = f"rm -r {filename}" + ProcessUtilities.executioner(command) + obj = RemoteBackupSchedule.objects.get(pk=config.id) + obj.lastrun = time.time() + obj.save() except BaseException as msg: - print("Error Wpsite: %s"%str(msg)) continue except BaseException as msg: print("Error: [RemoteBackup]: %s"%str(msg)) diff --git a/plogical/applicationInstaller.py b/plogical/applicationInstaller.py index 128d9bc66..5685f7f83 100755 --- a/plogical/applicationInstaller.py +++ b/plogical/applicationInstaller.py @@ -2261,6 +2261,10 @@ $parameters = array( wpsite = WPSites.objects.get(pk=self.extraArgs['WPid']) Adminobj = Administrator.objects.get(pk=self.extraArgs['adminID']) Backuptype = self.extraArgs['Backuptype'] + try: + BackupDestination = self.extraArgs['BackupDestination'] + except: + BackupDestination = 'Local' website = wpsite.owner PhpVersion = website.phpSelection @@ -2344,6 +2348,7 @@ $parameters = array( config['Webadmin_id'] = website.admin_id config['name'] = 'backup-' + websitedomain + "-" + time.strftime("%m.%d.%Y_%H-%M-%S") config['Backuptype'] = "Both Website and DataBase" + config['BackupDestination'] = BackupDestination ###############Create config.Json file #command = "sudo -u %s touch /home/cyberpanel/config.json" % (VHuser) @@ -2489,6 +2494,7 @@ $parameters = array( config['Webadmin_id'] = website.admin_id config['name'] = 'backup-' + websitedomain + "-" + time.strftime("%m.%d.%Y_%H-%M-%S") config['Backuptype'] = "Website Backup" + config['BackupDestination'] = BackupDestination ###############Create config.Json file # command = "sudo -u %s touch /home/cyberpanel/config.json" % (VHuser) @@ -2632,6 +2638,7 @@ $parameters = array( config['Webadmin_id'] = website.admin_id config['name'] = 'backup-' + websitedomain + "-" + time.strftime("%m.%d.%Y_%H-%M-%S") config['Backuptype'] = "DataBase Backup" + config['BackupDestination'] = BackupDestination ###############Create config.Json file # command = "sudo -u %s touch /home/cyberpanel/config.json" % (VHuser) # ProcessUtilities.executioner(command) diff --git a/websiteFunctions/templates/websiteFunctions/RestoreBackups.html b/websiteFunctions/templates/websiteFunctions/RestoreBackups.html index e5f18e4c1..5fa22c86c 100644 --- a/websiteFunctions/templates/websiteFunctions/RestoreBackups.html +++ b/websiteFunctions/templates/websiteFunctions/RestoreBackups.html @@ -102,6 +102,8 @@