From 2fab5982a4e52ef9faf02e463b8e3bfa509717bd Mon Sep 17 00:00:00 2001 From: Zarak Khan Date: Thu, 22 Feb 2024 11:35:06 +0500 Subject: [PATCH] Review Code --- IncBackups/static/IncBackups/IncBackupsV2.js | 1884 +++++++++++++++++ .../IncBackups/ConfigureV2BackupV2.html | 130 ++ .../IncBackups/CreateV2BackupV2.html | 133 ++ .../IncBackups/ScheduleV2BackupV2.html | 229 ++ .../IncBackups/backupScheduleV2.html | 193 ++ .../templates/IncBackups/createBackupV2.html | 140 ++ .../IncBackups/incrementalDestinationsV2.html | 156 ++ .../IncBackups/restoreRemoteBackupsV2.html | 125 ++ IncBackups/urls.py | 9 +- IncBackups/views.py | 192 +- backup/backupManager.py | 50 + backup/static/backup/backupV2.js | 1542 ++++++++++++++ .../backup/backupDestinationsV2.html | 194 ++ backup/templates/backup/backupScheduleV2.html | 299 +++ backup/templates/backup/googleDriveV2.html | 287 +++ backup/templates/backup/remoteBackupsV2.html | 146 ++ backup/urls.py | 4 + backup/views.py | 36 + .../templates/baseTemplate/dashboardV2.html | 35 +- .../templates/baseTemplate/newBase.html | 36 +- .../templates/databases/listDataBasesV2.html | 285 +-- .../dns/addDeleteDNSRecordsCloudFlareV2.html | 9 +- dns/templates/dns/addDeleteDNSRecordsV2.html | 9 +- .../dns/configureDefaultNameServersV2.html | 8 +- dns/templates/dns/createDNSZoneV2.html | 8 +- dns/templates/dns/createNameServerV2.html | 8 +- dns/templates/dns/deleteDNSZoneV2.html | 8 +- emailMarketing/emailMarketingManager.py | 62 +- .../static/emailMarketing/emailMarketingV2.js | 395 ++++ .../emailMarketing/composeMessagesV2.html | 79 + .../emailMarketing/createEmailListV2.html | 71 + .../emailMarketing/manageListsV2.html | 222 ++ .../emailMarketing/manageSMTPHostsV2.html | 142 ++ emailMarketing/urls.py | 5 +- emailMarketing/views.py | 46 +- .../mailServer/deleteEmailAccountV2.html | 2 +- .../templates/mailServer/listEmailsV2.html | 4 +- manageSSL/static/manageSSL/manageSSLV2.js | 288 +++ .../templates/manageSSL/manageSSLV2.html | 64 + .../templates/manageSSL/sslForHostNameV2.html | 65 + .../manageSSL/sslForMailServerV2.html | 62 + .../templates/manageSSL/v2ManageSSLV2.html | 167 ++ manageSSL/urls.py | 6 +- manageSSL/views.py | 66 +- .../templates/packages/createPackageV2.html | 4 +- .../templates/packages/listPackagesV2.html | 578 +++-- .../templates/packages/modifyPackageV2.html | 4 +- .../templates/userManagment/listUsers.html | 1 + .../templates/userManagment/listUsersV2.html | 382 ++-- .../websiteFunctions/websiteFunctionsV2.js | 850 +++++++- .../websiteFunctions/AddRemoteBackupSite.html | 1 - .../AddRemoteBackupSiteV2.html | 82 + .../websiteFunctions/ApacheManagerV2.html | 347 +++ .../websiteFunctions/BackupfileConfig.html | 1 - .../websiteFunctions/BackupfileConfigV2.html | 229 ++ .../RemoteBackupConfigV2.html | 232 ++ .../websiteFunctions/RestoreBackupsV2.html | 129 +- .../WPConfigurePluginsV2.html | 68 +- .../websiteFunctions/WPCreateV2.html | 2 +- .../websiteFunctions/WPEditPluginV2.html | 2 +- .../websiteFunctions/WPRestoreHome.html | 2 - .../websiteFunctions/WPRestoreHomeV2.html | 127 ++ .../websiteFunctions/WPsitesListV2.html | 364 ++-- .../websiteFunctions/createDomainV2.html | 63 +- .../websiteFunctions/createWebsiteV2.html | 36 +- .../websiteFunctions/deleteWebsiteV2.html | 8 +- .../websiteFunctions/listChildDomainsV2.html | 361 +++- .../websiteFunctions/listWebsiteV2.html | 2 +- .../websiteFunctions/modifyWebsiteV2.html | 31 +- .../websiteFunctions/suspendWebsiteV2.html | 32 +- .../templates/websiteFunctions/websiteV2.html | 19 +- websiteFunctions/urls.py | 2 +- websiteFunctions/views.py | 55 + websiteFunctions/website.py | 168 ++ websitesv2/urls.py | 6 +- 75 files changed, 11067 insertions(+), 1022 deletions(-) create mode 100644 IncBackups/static/IncBackups/IncBackupsV2.js create mode 100644 IncBackups/templates/IncBackups/ConfigureV2BackupV2.html create mode 100644 IncBackups/templates/IncBackups/CreateV2BackupV2.html create mode 100644 IncBackups/templates/IncBackups/ScheduleV2BackupV2.html create mode 100644 IncBackups/templates/IncBackups/backupScheduleV2.html create mode 100644 IncBackups/templates/IncBackups/createBackupV2.html create mode 100644 IncBackups/templates/IncBackups/incrementalDestinationsV2.html create mode 100644 IncBackups/templates/IncBackups/restoreRemoteBackupsV2.html create mode 100644 backup/templates/backup/backupDestinationsV2.html create mode 100644 backup/templates/backup/backupScheduleV2.html create mode 100644 backup/templates/backup/googleDriveV2.html create mode 100644 backup/templates/backup/remoteBackupsV2.html create mode 100644 emailMarketing/static/emailMarketing/emailMarketingV2.js create mode 100644 emailMarketing/templates/emailMarketing/composeMessagesV2.html create mode 100644 emailMarketing/templates/emailMarketing/createEmailListV2.html create mode 100644 emailMarketing/templates/emailMarketing/manageListsV2.html create mode 100644 emailMarketing/templates/emailMarketing/manageSMTPHostsV2.html create mode 100644 manageSSL/static/manageSSL/manageSSLV2.js create mode 100644 manageSSL/templates/manageSSL/manageSSLV2.html create mode 100644 manageSSL/templates/manageSSL/sslForHostNameV2.html create mode 100644 manageSSL/templates/manageSSL/sslForMailServerV2.html create mode 100644 manageSSL/templates/manageSSL/v2ManageSSLV2.html create mode 100644 websiteFunctions/templates/websiteFunctions/AddRemoteBackupSiteV2.html create mode 100644 websiteFunctions/templates/websiteFunctions/ApacheManagerV2.html create mode 100644 websiteFunctions/templates/websiteFunctions/BackupfileConfigV2.html create mode 100644 websiteFunctions/templates/websiteFunctions/RemoteBackupConfigV2.html create mode 100644 websiteFunctions/templates/websiteFunctions/WPRestoreHomeV2.html diff --git a/IncBackups/static/IncBackups/IncBackupsV2.js b/IncBackups/static/IncBackups/IncBackupsV2.js new file mode 100644 index 000000000..2eb04a2f5 --- /dev/null +++ b/IncBackups/static/IncBackups/IncBackupsV2.js @@ -0,0 +1,1884 @@ +newapp.controller('CreateV2BackupV2', function ($scope, $http, $timeout, $compile) { + + + $scope.backupLoading = true; + $scope.installationProgress = true; + $scope.errorMessageBox = true; + $scope.success = true; + $scope.couldNotConnect = true; + $scope.goBackDisable = true; + + $scope.selectwebsite = function () { + document.getElementById('reposelectbox').innerHTML = ""; + $scope.backupLoading = false; + // document.getElementById('CreateV2BackupButton').style.display = "block"; + var url = "/IncrementalBackups/selectwebsiteCreatev2"; + + var data = { + Selectedwebsite: $scope.selwebsite, + Selectedrepo: $('#reposelectbox').val(), + }; + //alert( $scope.selwebsite); + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.backupLoading = true; + if (response.data.status === 1) { + + const selectBox = document.getElementById('reposelectbox'); + + + const options = response.data.data; + const option = document.createElement('option'); + + + option.value = 1; + option.text = 'Choose Repo'; + + selectBox.appendChild(option); + + if (options.length >= 1) { + for (let i = 0; i < options.length; i++) { + + const option = document.createElement('option'); + + + option.value = options[i]; + option.text = options[i]; + + selectBox.appendChild(option); + } + + } else { + new PNotify({ + title: 'Error!', + text: 'file empty', + type: 'error' + }); + } + + + } else { + new PNotify({ + title: 'Error!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + $scope.backupLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + } + + var Domain; + + $scope.CreateV2BackupButton = function () { + $scope.backupLoading = false; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = true; + $scope.success = true; + $scope.couldNotConnect = true; + $scope.goBackDisable = true; + + var url = "/IncrementalBackups/CreateV2BackupButton"; + var websiteData = $scope.websiteData; + var websiteEmails = $scope.websiteEmails; + var websiteDatabases = $scope.websiteDatabases; + var chk = 0; + if (websiteData === true || websiteDatabases === true || websiteEmails === true) { + chk = 1; + } + var data = {}; + + + data = { + Selectedwebsite: $scope.selwebsite, + Selectedrepo: $('#reposelectbox').val(), + websiteDatabases: websiteDatabases, + websiteEmails: websiteEmails, + websiteData: websiteData, + + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + //alert('Done..........') + if (chk === 1) { + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + } else { + $scope.backupLoading = true; + new PNotify({ + title: 'Choose Backup Content!', + text: 'Please Choose Backup content Data, Database, Email', + type: 'error' + }); + } + + + function ListInitialDatas(response) { + if (response.data.status === 1) { + + Domain = $scope.selwebsite; + getCreationStatus(); + + } else { + $scope.backupLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = false; + $scope.success = true; + $scope.couldNotConnect = true; + $scope.goBackDisable = false; + + $scope.errorMessage = response.data.error_message; + } + + } + + function cantLoadInitialDatas(response) { + $scope.backupLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + } + + + function getCreationStatus() { + + url = "/IncrementalBackups/CreateV2BackupStatus"; + + var data = { + domain: Domain + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + if (response.data.abort === 1) { + $scope.backupLoading = true; + if (response.data.installStatus === 1) { + + $scope.webSiteCreationLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = true; + $scope.success = false; + $scope.couldNotConnect = true; + $scope.goBackDisable = false; + + $("#installProgress").css("width", "100%"); + $scope.installPercentage = "100"; + $scope.currentStatus = response.data.currentStatus; + $timeout.cancel(); + + } else { + $scope.webSiteCreationLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = false; + $scope.success = true; + $scope.couldNotConnect = true; + $scope.goBackDisable = false; + + $scope.errorMessage = response.data.error_message; + + $("#installProgress").css("width", "0%"); + $scope.installPercentage = "0"; + $scope.goBackDisable = false; + + } + + } else { + $scope.webSiteCreationLoading = false; + $("#installProgress").css("width", response.data.installationProgress + "%"); + $scope.installPercentage = response.data.installationProgress; + $scope.currentStatus = response.data.currentStatus; + $timeout(getCreationStatus, 1000); + } + + } + + function cantLoadInitialDatas(response) { + + $scope.webSiteCreationLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = true; + $scope.success = true; + $scope.couldNotConnect = false; + $scope.goBackDisable = false; + + } + + + } + + +}); +newapp.controller('ConfigureV2BackupV2', function ($scope, $http, $timeout) { + $scope.cyberpanelLoading = true; + $scope.selectbackuptype = function () { + + $scope.cyberpanelLoading = false; + + var backuptype = $scope.v2backuptype + if (backuptype === 'GDrive') { + $scope.cyberpanelLoading = true; + $('#GdriveModal').modal('show'); + } else if (backuptype === 'SFTP') { + $scope.cyberpanelLoading = true; + $('#SFTPModal').modal('show'); + } + } + + + $scope.setupAccount = function () { + window.open("https://platform.cyberpersons.com/gDrive?name=" + $scope.accountName + '&server=' + window.location.href + 'Setup&domain=' + $scope.selwebsite); + }; + + $scope.ConfigerSFTP = function () { + $scope.cyberpanelLoading = false; + var url = "/IncrementalBackups/ConfigureSftpV2Backup"; + + var data = { + Selectedwebsite: $scope.selwebsite, + sfptpasswd: $scope.sfptpasswd, + hostName: $scope.hostName, + UserName: $scope.UserName, + Repo_Name: $scope.reponame, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.backupLoading = true; + if (response.data.status === 1) { + location.reload() + + } else { + $scope.goBackDisable = false; + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + $scope.backupLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + } +}); +newapp.controller('ScheduleV2BackupV2', function ($scope, $http, $timeout, $compile) { + + + $scope.backupLoading = true; + $scope.installationProgress = true; + $scope.errorMessageBox = true; + $scope.success = true; + $scope.couldNotConnect = true; + $scope.goBackDisable = true; + + var repoG, frequencyG, websiteDataG, websiteDatabasesG, websiteEmailsG; + + $scope.deleteBackupInitialv2 = function (repo, frequency, websiteData, websiteDatabases, websiteEmails) { + repoG = repo; + frequencyG = frequency; + websiteDataG = websiteData; + websiteDatabasesG = websiteDatabases; + websiteEmailsG = websiteEmails; + } + + $scope.DeleteScheduleV2 = function () { + $scope.backupLoading = false; + // document.getElementById('CreateV2BackupButton').style.display = "block"; + var url = "/IncrementalBackups/DeleteScheduleV2"; + + var data = { + Selectedwebsite: $scope.selwebsite, + repo: repoG, + frequency: frequencyG, + websiteData: websiteDataG, + websiteDatabases: websiteDatabasesG, + websiteEmails: websiteEmailsG + }; + //alert( $scope.selwebsite); + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.backupLoading = true; + if (response.data.status === 1) { + $scope.selectwebsite(); + new PNotify({ + title: 'Success!', + text: 'Successfully deleted.', + type: 'success' + }); + + } else { + new PNotify({ + title: 'Error!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + $scope.backupLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + } + + $scope.selectwebsite = function () { + document.getElementById('reposelectbox').innerHTML = ""; + $scope.backupLoading = false; + // document.getElementById('CreateV2BackupButton').style.display = "block"; + var url = "/IncrementalBackups/selectwebsiteCreatev2"; + + var data = { + Selectedwebsite: $scope.selwebsite, + Selectedrepo: $('#reposelectbox').val(), + }; + //alert( $scope.selwebsite); + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.backupLoading = true; + if (response.data.status === 1) { + + const selectBox = document.getElementById('reposelectbox'); + + + const options = response.data.data; + const option = document.createElement('option'); + $scope.records = response.data.currentSchedules; + + + option.value = 1; + option.text = 'Choose Repo'; + + selectBox.appendChild(option); + + if (options.length >= 1) { + for (let i = 0; i < options.length; i++) { + + const option = document.createElement('option'); + + + option.value = options[i]; + option.text = options[i]; + + selectBox.appendChild(option); + } + + } else { + new PNotify({ + title: 'Error!', + text: 'file empty', + type: 'error' + }); + } + + + } else { + new PNotify({ + title: 'Error!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + $scope.backupLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + } + + $scope.CreateScheduleV2 = function () { + $scope.backupLoading = false; + // document.getElementById('CreateV2BackupButton').style.display = "block"; + var url = "/IncrementalBackups/CreateScheduleV2"; + + var data = { + Selectedwebsite: $scope.selwebsite, + repo: $('#reposelectbox').val(), + frequency: $scope.frequency, + websiteData: $scope.websiteData, + websiteDatabases: $scope.websiteDatabases, + websiteEmails: $scope.websiteEmails, + retention: $scope.retention + }; + //alert( $scope.selwebsite); + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.backupLoading = true; + if (response.data.status === 1) { + $scope.selectwebsite(); + new PNotify({ + title: 'Success!', + text: 'Successfully created.', + type: 'success' + }); + + } else { + new PNotify({ + title: 'Error!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + $scope.backupLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + } + + var Domain; + + $scope.CreateV2BackupButton = function () { + $scope.backupLoading = false; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = true; + $scope.success = true; + $scope.couldNotConnect = true; + $scope.goBackDisable = true; + + var url = "/IncrementalBackups/CreateV2BackupButton"; + var websiteData = $scope.websiteData; + var websiteEmails = $scope.websiteEmails; + var websiteDatabases = $scope.websiteDatabases; + var chk = 0; + if (websiteData === true || websiteDatabases === true || websiteEmails === true) { + chk = 1; + } + var data = {}; + + + data = { + Selectedwebsite: $scope.selwebsite, + Selectedrepo: $('#reposelectbox').val(), + websiteDatabases: websiteDatabases, + websiteEmails: websiteEmails, + websiteData: websiteData, + + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + //alert('Done..........') + if (chk === 1) { + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + } else { + $scope.backupLoading = true; + new PNotify({ + title: 'Choose Backup Content!', + text: 'Please Choose Backup content Data, Database, Email', + type: 'error' + }); + } + + + function ListInitialDatas(response) { + $scope.backupLoading = true; + if (response.data.status === 1) { + + Domain = $scope.selwebsite; + getCreationStatus(); + + } else { + $scope.backupLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = false; + $scope.success = true; + $scope.couldNotConnect = true; + $scope.goBackDisable = false; + + $scope.errorMessage = response.data.error_message; + } + + } + + function cantLoadInitialDatas(response) { + $scope.backupLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + } + + function getCreationStatus() { + + url = "/IncrementalBackups/CreateV2BackupStatus"; + + var data = { + domain: Domain + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + if (response.data.abort === 1) { + + if (response.data.installStatus === 1) { + + $scope.webSiteCreationLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = true; + $scope.success = false; + $scope.couldNotConnect = true; + $scope.goBackDisable = false; + + $("#installProgress").css("width", "100%"); + $scope.installPercentage = "100"; + $scope.currentStatus = response.data.currentStatus; + $timeout.cancel(); + + } else { + $scope.webSiteCreationLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = false; + $scope.success = true; + $scope.couldNotConnect = true; + $scope.goBackDisable = false; + + $scope.errorMessage = response.data.error_message; + + $("#installProgress").css("width", "0%"); + $scope.installPercentage = "0"; + $scope.goBackDisable = false; + + } + + } else { + $scope.webSiteCreationLoading = false; + $("#installProgress").css("width", response.data.installationProgress + "%"); + $scope.installPercentage = response.data.installationProgress; + $scope.currentStatus = response.data.currentStatus; + $timeout(getCreationStatus, 1000); + } + + } + + function cantLoadInitialDatas(response) { + + $scope.webSiteCreationLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = true; + $scope.success = true; + $scope.couldNotConnect = false; + $scope.goBackDisable = false; + + } + + + } + + +}); +newapp.controller('createIncrementalBackupsV2', function ($scope, $http, $timeout) { + + $scope.destination = true; + $scope.backupButton = true; + $scope.cyberpanelLoading = true; + $scope.runningBackup = true; + $scope.restoreSt = true; + + + $scope.fetchDetails = function () { + getBackupStatus(); + $scope.populateCurrentRecords(); + $scope.destination = false; + $scope.runningBackup = true; + }; + + function getBackupStatus() { + + $scope.cyberpanelLoadingBottom = false; + + url = "/IncrementalBackups/getBackupStatus"; + + var data = { + websiteToBeBacked: $scope.websiteToBeBacked, + tempPath: $scope.tempPath + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.backupStatus === 1) { + + if (response.data.abort === 1) { + $timeout.cancel(); + $scope.cyberpanelLoadingBottom = true; + $scope.destination = false; + $scope.runningBackup = false; + $scope.backupButton = false; + $scope.cyberpanelLoading = true; + $scope.fileName = response.data.fileName; + $scope.status = response.data.status; + $scope.populateCurrentRecords(); + return; + } else { + $scope.destination = true; + $scope.backupButton = true; + $scope.runningBackup = false; + + $scope.fileName = response.data.fileName; + $scope.status = response.data.status; + $timeout(getBackupStatus, 2000); + + } + } else { + $timeout.cancel(); + $scope.cyberpanelLoadingBottom = true; + $scope.cyberpanelLoading = true; + $scope.backupButton = false; + } + + } + + function cantLoadInitialDatas(response) { + } + + } + + $scope.destinationSelection = function () { + $scope.backupButton = false; + }; + + $scope.populateCurrentRecords = function () { + + url = "/IncrementalBackups/fetchCurrentBackups"; + + var data = { + websiteToBeBacked: $scope.websiteToBeBacked, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + if (response.data.status === 1) { + $scope.records = response.data.data; + } else { + new PNotify({ + title: 'Error!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + }; + + $scope.createBackup = function () { + + $scope.status = ''; + + $scope.cyberpanelLoading = false; + + + url = "/IncrementalBackups/submitBackupCreation"; + + var data = { + websiteToBeBacked: $scope.websiteToBeBacked, + backupDestinations: $scope.backupDestinations, + websiteData: $scope.websiteData, + websiteEmails: $scope.websiteEmails, + websiteSSLs: $scope.websiteSSLs, + websiteDatabases: $scope.websiteDatabases + + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + if (response.data.status === 1) { + $scope.tempPath = response.data.tempPath; + getBackupStatus(); + } else { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + } + + }; + + // $scope.RestoreV2Backup = function () { + // + // // $scope.status = ''; + // // + // // $scope.cyberpanelLoading = false; + // // + // // + // // url = "/IncrementalBackups/submitBackupCreation"; + // + // + // console.log($scope.websiteToBeBacked) + // console.log($scope.websiteData) + // var websites = document.getElementById('create-backup-select'); + // var selected_website = websites.options[websites.selectedIndex].innerHTML; + // console.log(selected_website); + // + // var data = { + // websiteToBeBacked: $scope.websiteToBeBacked, + // backupDestinations: $scope.backupDestinations, + // websiteData: $scope.websiteData, + // websiteEmails: $scope.websiteEmails, + // websiteSSLs: $scope.websiteSSLs, + // websiteDatabases: $scope.websiteDatabases + // + // }; + // + // // var config = { + // // headers: { + // // 'X-CSRFToken': getCookie('csrftoken') + // // } + // // }; + // // + // // + // // $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + // // + // // + // // function ListInitialDatas(response) { + // // + // // if (response.data.status === 1) { + // // $scope.tempPath = response.data.tempPath; + // // getBackupStatus(); + // // } else { + // // $scope.cyberpanelLoading = true; + // // new PNotify({ + // // title: 'Operation Failed!', + // // text: response.data.error_message, + // // type: 'error' + // // }); + // // } + // // + // // } + // // + // // function cantLoadInitialDatas(response) { + // // } + // + // }; + + $scope.deleteBackup = function (id) { + + + url = "/IncrementalBackups/deleteBackup"; + + var data = { + backupID: id, + websiteToBeBacked: $scope.websiteToBeBacked + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.status === 1) { + + $scope.populateCurrentRecords(); + + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + } + + + }; + + $scope.restore = function (id) { + + $scope.cyberpanelLoading = false; + + + url = "/IncrementalBackups/fetchRestorePoints"; + + var data = { + id: id, + websiteToBeBacked: $scope.websiteToBeBacked + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + $scope.jobs = response.data.data; + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + }; + + $scope.restorePoint = function (id, reconstruct) { + + $scope.status = ''; + + $scope.cyberpanelLoading = false; + $scope.restoreSt = false; + + + url = "/IncrementalBackups/restorePoint"; + + var data = { + websiteToBeBacked: $scope.websiteToBeBacked, + jobid: id, + reconstruct: reconstruct + + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + if (response.data.status === 1) { + $scope.tempPath = response.data.tempPath; + getBackupStatus(); + } + + } + + function cantLoadInitialDatas(response) { + } + + }; + + +}); +newapp.controller('incrementalDestinationsV2', function ($scope, $http) { + $scope.cyberpanelLoading = true; + $scope.sftpHide = true; + $scope.awsHide = true; + + $scope.fetchDetails = function () { + + if ($scope.destinationType === 'SFTP') { + $scope.sftpHide = false; + $scope.awsHide = true; + $scope.populateCurrentRecords(); + } else { + $scope.sftpHide = true; + $scope.awsHide = false; + $scope.populateCurrentRecords(); + } + }; + + $scope.populateCurrentRecords = function () { + + $scope.cyberpanelLoading = false; + + + url = "/IncrementalBackups/populateCurrentRecords"; + + var type = 'SFTP'; + if ($scope.destinationType === 'SFTP') { + type = 'SFTP'; + } else { + type = 'AWS'; + } + + var data = { + type: type + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + $scope.records = response.data.data; + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + }; + + $scope.addDestination = function (type) { + $scope.cyberpanelLoading = false; + + + url = "/IncrementalBackups/addDestination"; + + if (type === 'SFTP') { + var data = { + type: type, + IPAddress: $scope.IPAddress, + password: $scope.password, + backupSSHPort: $scope.backupSSHPort + }; + } else { + var data = { + type: type, + AWS_ACCESS_KEY_ID: $scope.AWS_ACCESS_KEY_ID, + AWS_SECRET_ACCESS_KEY: $scope.AWS_SECRET_ACCESS_KEY, + }; + } + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberpanelLoading = true; + $scope.populateCurrentRecords(); + if (response.data.status === 1) { + new PNotify({ + title: 'Success!', + text: 'Destination successfully added.', + type: 'success' + }); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + }; + + $scope.removeDestination = function (type, ipAddress) { + $scope.cyberpanelLoading = false; + + + url = "/IncrementalBackups/removeDestination"; + + var data = { + type: type, + IPAddress: ipAddress, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberpanelLoading = true; + $scope.populateCurrentRecords(); + if (response.data.status === 1) { + new PNotify({ + title: 'Success!', + text: 'Destination successfully removed.', + type: 'success' + }); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + }; + + +}); +newapp.controller('scheduleBackupIncV2', function ($scope, $http) { + + var globalPageNumber; + $scope.scheduleFreq = true; + $scope.cyberpanelLoading = true; + $scope.getFurtherWebsitesFromDB = function (pageNumber) { + $scope.cyberpanelLoading = false; + globalPageNumber = pageNumber; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + var data = {page: pageNumber}; + + + dataurl = "/CloudLinux/submitWebsiteListing"; + + $http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData); + + + function ListInitialData(response) { + $scope.cyberpanelLoading = true; + if (response.data.listWebSiteStatus === 1) { + var finalData = JSON.parse(response.data.data); + $scope.WebSitesList = finalData; + $scope.pagination = response.data.pagination; + $scope.default = response.data.default; + $("#listFail").hide(); + } else { + $("#listFail").fadeIn(); + $scope.errorMessage = response.data.error_message; + console.log(response.data); + + } + } + + function cantLoadInitialData(response) { + $scope.cyberpanelLoading = true; + } + + + }; + + var websitesToBeBacked = []; + var websitesToBeBackedTemp = []; + + var index = 0; + var tempTransferDir = ""; + $scope.addRemoveWebsite = function (website, websiteStatus) { + + if (websiteStatus === true) { + var check = 1; + for (var j = 0; j < websitesToBeBacked.length; j++) { + if (websitesToBeBacked[j] == website) { + check = 0; + break; + } + } + if (check == 1) { + websitesToBeBacked.push(website); + } + + } else { + + var tempArray = []; + + for (var j = 0; j < websitesToBeBacked.length; j++) { + if (websitesToBeBacked[j] != website) { + tempArray.push(websitesToBeBacked[j]); + } + } + websitesToBeBacked = tempArray; + } + }; + + $scope.allChecked = function (webSiteStatus) { + if (webSiteStatus === true) { + + websitesToBeBacked = websitesToBeBackedTemp; + $scope.webSiteStatus = true; + } else { + websitesToBeBacked = []; + $scope.webSiteStatus = false; + } + }; + + $scope.scheduleFreqView = function () { + $scope.scheduleFreq = false; + $scope.getFurtherWebsitesFromDB(1); + + }; + $scope.addSchedule = function () { + $scope.cyberpanelLoading = false; + + + url = "/IncrementalBackups/submitBackupSchedule"; + + var data = { + backupDestinations: $scope.backupDest, + backupFreq: $scope.backupFreq, + backupRetention: $scope.backupRetention, + websiteData: $scope.websiteData, + websiteEmails: $scope.websiteEmails, + websiteDatabases: $scope.websiteDatabases, + websitesToBeBacked: websitesToBeBacked + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberpanelLoading = true; + $scope.populateCurrentRecords(); + if (response.data.status === 1) { + new PNotify({ + title: 'Success!', + text: 'Operation successful.', + type: 'success' + }); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + }; + + $scope.populateCurrentRecords = function () { + + $scope.cyberpanelLoading = false; + + + url = "/IncrementalBackups/getCurrentBackupSchedules"; + + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + let data = response.data.data; + $scope.records = data; + data.forEach(item => { + websitesToBeBackedTemp.push(item.website) + }) + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + }; + $scope.populateCurrentRecords(); + + $scope.delSchedule = function (id) { + + $scope.cyberpanelLoading = false; + + url = "/IncrementalBackups/scheduleDelete"; + + + var data = {id: id}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberpanelLoading = true; + + if (response.data.status === 1) { + $scope.populateCurrentRecords(); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + }; + + $scope.editInitial = function (id) { + + $scope.jobID = id; + + $scope.cyberpanelLoading = false; + + + url = "/IncrementalBackups/fetchSites"; + + + var data = {id: id}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + $scope.websites = response.data.data; + + if (response.data.websiteData === 1) { + $scope.websiteData = true; + } + if (response.data.websiteDatabases === 1) { + $scope.websiteDatabases = true; + } + if (response.data.websiteEmails === 1) { + $scope.websiteEmails = true; + } + + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + }; + + $scope.saveChanges = function () { + + $scope.cyberpanelLoading = false; + + url = "/IncrementalBackups/saveChanges"; + + + var data = { + id: $scope.jobID, + websiteData: $scope.websiteData, + websiteDatabases: $scope.websiteDatabases, + websiteEmails: $scope.websiteEmails + + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberpanelLoading = true; + + if (response.data.status === 1) { + $scope.editInitial($scope.jobID); + new PNotify({ + title: 'Success!', + text: 'Operation successful.', + type: 'success' + }); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + }; + + $scope.removeSite = function (website) { + + $scope.cyberpanelLoading = false; + + url = "/IncrementalBackups/removeSite"; + + + var data = { + id: $scope.jobID, + website: website + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberpanelLoading = true; + + if (response.data.status === 1) { + $scope.editInitial($scope.jobID); + new PNotify({ + title: 'Success!', + text: 'Operation successful.', + type: 'success' + }); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + }; + + $scope.cyberpanelLoading = true; + + $scope.addWebsite = function () { + + $scope.cyberpanelLoading = false; + + url = "/IncrementalBackups/addWebsite"; + + + var data = { + id: $scope.jobID, + website: $scope.websiteToBeAdded + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberpanelLoading = true; + + if (response.data.status === 1) { + $scope.editInitial($scope.jobID); + new PNotify({ + title: 'Success!', + text: 'Operation successful.', + type: 'success' + }); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + }; + + +}); +newapp.controller('restoreRemoteBackupsIncV2', function ($scope, $http, $timeout) { + + $scope.destination = true; + $scope.backupButton = true; + $scope.cyberpanelLoading = true; + $scope.runningBackup = true; + $scope.restoreSt = true; + + $scope.showThings = function () { + $scope.destination = false; + $scope.runningBackup = true; + }; + + $scope.fetchDetails = function () { + $scope.populateCurrentRecords(); + }; + + function getBackupStatus() { + + $scope.cyberpanelLoadingBottom = false; + + url = "/IncrementalBackups/getBackupStatus"; + + var data = { + websiteToBeBacked: $scope.websiteToBeBacked, + tempPath: $scope.tempPath + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.backupStatus === 1) { + + if (response.data.abort === 1) { + $timeout.cancel(); + $scope.cyberpanelLoadingBottom = true; + $scope.destination = false; + $scope.runningBackup = false; + $scope.backupButton = false; + $scope.cyberpanelLoading = true; + $scope.fileName = response.data.fileName; + $scope.status = response.data.status; + $scope.populateCurrentRecords(); + return; + } else { + $scope.destination = true; + $scope.backupButton = true; + $scope.runningBackup = false; + + $scope.fileName = response.data.fileName; + if (response.data.status === 1) { + $scope.status = 'Fetching status..' + } else { + $scope.status = response.data.status; + } + + $timeout(getBackupStatus, 2000); + + } + } else { + $timeout.cancel(); + $scope.cyberpanelLoadingBottom = true; + $scope.cyberpanelLoading = true; + $scope.backupButton = false; + } + + } + + function cantLoadInitialDatas(response) { + } + + } + + $scope.populateCurrentRecords = function () { + $scope.cyberpanelLoading = false; + + url = "/IncrementalBackups/fetchCurrentBackups"; + + var data = { + websiteToBeBacked: $scope.websiteToBeBacked, + backupDestinations: $scope.backupDestinations, + password: $scope.password + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + $scope.records = response.data.data; + } else { + new PNotify({ + title: 'Error!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + }; + + $scope.restorePoint = function (id, path) { + + $scope.status = ''; + + $scope.cyberpanelLoading = false; + $scope.restoreSt = false; + + + url = "/IncrementalBackups/restorePoint"; + + var data = { + websiteToBeBacked: $scope.websiteToBeBacked, + jobid: id, + reconstruct: 'remote', + path: path, + backupDestinations: $scope.backupDestinations, + password: $scope.password + + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + if (response.data.status === 1) { + $scope.tempPath = response.data.tempPath; + getBackupStatus(); + } + + } + + function cantLoadInitialDatas(response) { + } + + }; + + +}); \ No newline at end of file diff --git a/IncBackups/templates/IncBackups/ConfigureV2BackupV2.html b/IncBackups/templates/IncBackups/ConfigureV2BackupV2.html new file mode 100644 index 000000000..4ef96894f --- /dev/null +++ b/IncBackups/templates/IncBackups/ConfigureV2BackupV2.html @@ -0,0 +1,130 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + + {% if BackupStat %} +
+
+

Configure v2 Backup Destinations

+ +
+
+
+
+

Select Website

+
+
+ +
+
+
+
+

Select Backup Type

+
+
+ +
+
+ {#
#} + {#
#} + {# #} + {#
#} + {#
#} + {#
#} + {#
#} + {#
#} + {#

{$ currentStatus $}

#} + {#
#} + {#
#} + {#
#} + {#
#} + {#
#} + {#
#} + {#

{% trans "Error message:" %} {$ errorMessage $}

#} + {#
#} + {#
#} + {#

{% trans "Backup succesfully." %}

#} + {#
#} + {#
#} + {#

{% trans "Could not connect to server. Please refresh this page." %}

#} + {#
#} + {#
#} + {#
#} + {#
#} + {#
#} + {# #} + {#
#} + {#
#} +
+ {% else %} + +
+
+

Backups v2 - Incremental Backups!

+

Is your website's data protection strategy up + to par? Are you tired of dealing with slow and unreliable backup solutions that don't offer the + level of robustness you need?

+ + Introducing CyberPanel's latest feature, Backups v2! With Backups v2, you can ensure that your + website's data is protected like never before. Our advanced incremental backup system utilizes + rclone, a powerful backup tool that supports over 30+ backends, including popular cloud storage + providers like Google Drive, Dropbox, Amazon S3, and more!

+ + Gone are the days of slow and cumbersome full backups. With Backups v2, you can take advantage of + incremental backups that only capture changes to your data, making the process lightning-fast and + highly efficient. This means you can save time and bandwidth while still maintaining the highest + level of data integrity.

+ + Whether you have a small blog or a large e-commerce website, Backups v2 is tailored to meet your + needs. With its robustness and versatility, you can have peace of mind knowing that your website's + data is backed up securely and can be easily restored whenever you need it. +

+
+

+ +

+
+ + + + + + +
+ +
+ {% endif %} +{% endblock %} diff --git a/IncBackups/templates/IncBackups/CreateV2BackupV2.html b/IncBackups/templates/IncBackups/CreateV2BackupV2.html new file mode 100644 index 000000000..8f16c8fe9 --- /dev/null +++ b/IncBackups/templates/IncBackups/CreateV2BackupV2.html @@ -0,0 +1,133 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + +
+
+
+

Create V2 Backup -

+ {% trans "Backup Docs" %} +
+
+

This page can be used to create your backup +

+
+

Create v2 Backup

+ + - Restore Backups +
+
+

+ +

+
+
+

Select Website

+
+
+ +
+
+
+
+

Select Repo

+
+
+ +
+
+
+
+

Backup Content

+
+
+
+ +
+
+
+
+
+

+
+
+
+ +
+
+
+
+
+

+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+

{$ currentStatus $}

+
+
+
+
+
+
+

{% trans "Error message:" %} {$ errorMessage $}

+
+
+

{% trans "Backup succesfully." %}

+
+
+

{% trans "Could not connect to server. Please refresh this page." %}

+
+
+
+
+
+ +
+
+
+{% endblock %} diff --git a/IncBackups/templates/IncBackups/ScheduleV2BackupV2.html b/IncBackups/templates/IncBackups/ScheduleV2BackupV2.html new file mode 100644 index 000000000..cf7532995 --- /dev/null +++ b/IncBackups/templates/IncBackups/ScheduleV2BackupV2.html @@ -0,0 +1,229 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + + {% if BackupStat %} +
+
+
+

Schedule V2 Backup -

+ {% trans "Backup Docs" %} +
+
+

This page can be used to schedule your backups. +

+
+

Schedule v2 Backup

+ +
+
+
+
+

Select Website

+
+
+ +
+
+
+
+

Backup Frequency

+
+
+ +
+
+
+
+

Select Repo

+
+
+ +
+
+
+
+

Backup Retention

+
+
+ +
+
+
+
+

Backup Content

+
+
+ +
+
+
+
+

+
+
+
+ +
+
+
+
+
+

+
+
+
+ +
+
+
+
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ Repo + + Frequency + + Retention + + Backup Websites? + + Backup Databases? + + Backup Emails? + + Last Run + + Delete +
+ + + + + + + +
+
+
+ {% else %} + +
+
+

Backups v2 - Incremental Backups!

+

Is your website's data protection strategy up + to par? Are you tired of dealing with slow and unreliable backup solutions that don't offer the + level of robustness you need?

+ + Introducing CyberPanel's latest feature, Backups v2! With Backups v2, you can ensure that your + website's data is protected like never before. Our advanced incremental backup system utilizes + rclone, a powerful backup tool that supports over 30+ backends, including popular cloud storage + providers like Google Drive, Dropbox, Amazon S3, and more!

+ + Gone are the days of slow and cumbersome full backups. With Backups v2, you can take advantage of + incremental backups that only capture changes to your data, making the process lightning-fast and + highly efficient. This means you can save time and bandwidth while still maintaining the highest + level of data integrity.

+ + Whether you have a small blog or a large e-commerce website, Backups v2 is tailored to meet your + needs. With its robustness and versatility, you can have peace of mind knowing that your website's + data is backed up securely and can be easily restored whenever you need it. +

+
+

+ +

+
+ + + + + + +
+ +
+ {% endif %} +{% endblock %} diff --git a/IncBackups/templates/IncBackups/backupScheduleV2.html b/IncBackups/templates/IncBackups/backupScheduleV2.html new file mode 100644 index 000000000..386a6a1f6 --- /dev/null +++ b/IncBackups/templates/IncBackups/backupScheduleV2.html @@ -0,0 +1,193 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + + +
+
+
+

Schedule Backup -

+ {% trans "Remote Backups" %} +
+
+

On this page you can schedule Backups to localhost or remote + server (If you have added one). +

+
+

Schedule Backup

+ +
+
+
+
+

Select Destination

+
+
+ +
+
+
+
+
+

Select Frequency

+
+
+ +
+
+
+
+

Select Backup Retention. Leave 0 for no limit

+
+
+ +
+
+
+
+
+

Backup Content

+
+
+ +
+
+
+
+

+
+
+ +
+
+
+
+

+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+ + + + + + + + + + + + + +
+ Select sites to be included in this job + + +
+ + +
+
+
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + +
+ ID + + Destination + + Frequency + + Sites + + Delete +
+ + + + + Delete Edit +
+
+
+{% endblock %} diff --git a/IncBackups/templates/IncBackups/createBackupV2.html b/IncBackups/templates/IncBackups/createBackupV2.html new file mode 100644 index 000000000..af868d9ca --- /dev/null +++ b/IncBackups/templates/IncBackups/createBackupV2.html @@ -0,0 +1,140 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + + +
+
+
+

Backup Website -

+ {% trans "Backup Docs" %} +
+
+

This page can be used to create incremental backups for your + websites. +

+
+

Backup Website

+ +
+
+
+
+

Select Website

+
+
+ +
+
+
+
+
+

Destination

+
+
+ +
+
+
+
+

Backup Content

+
+
+ +
+
+
+
+

+
+
+ +
+
+
+
+

+
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+ + + + + + + + + + + + + + + + + +
+ ID + + Date + + Restore + + Delete +
+ + + Restore + + +
+
+
+{% endblock %} diff --git a/IncBackups/templates/IncBackups/incrementalDestinationsV2.html b/IncBackups/templates/IncBackups/incrementalDestinationsV2.html new file mode 100644 index 000000000..a8e4326ad --- /dev/null +++ b/IncBackups/templates/IncBackups/incrementalDestinationsV2.html @@ -0,0 +1,156 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + + +
+
+
+

Set up Incremental Backup Destinations -

+ {% trans "Remote Backups" %} +
+
+

On this page you can set up your Backup destinations. (SFTP + and AWS) +

+
+

Set up Backup Destinations.

+ +
+
+
+
+

Select Type

+
+
+ +
+
+
+
+
+

IP Address

+
+
+ +
+
+
+
+

Password

+
+
+ +
+
+
+
+

Port

+
+
+ +
+
+
+
+ +
+
+
+
+ + + + + + + + + + + + + + + +
+ IP + + Port + + Delete +
+ + + +
+
+
+
+

AWS_ACCESS_KEY_ID

+
+
+ +
+
+
+
+

AWS_SECRET_ACCESS_KEY

+
+
+ +
+
+
+
+ +
+
+
+ + + + + + + + + + + + + +
+ AWS_ACCESS_KEY_ID + + Delete +
+ + +
+
+
+{% endblock %} diff --git a/IncBackups/templates/IncBackups/restoreRemoteBackupsV2.html b/IncBackups/templates/IncBackups/restoreRemoteBackupsV2.html new file mode 100644 index 000000000..ea326b328 --- /dev/null +++ b/IncBackups/templates/IncBackups/restoreRemoteBackupsV2.html @@ -0,0 +1,125 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + + +
+
+
+

Restore Remote Incremental Backups -

+ {% trans "Backup Docs" %} +
+
+

This page can be used to restore remote incremental backups + for your websites. +

+
+

Backup Website

+ +
+
+
+
+

Select Website

+
+
+ +
+
+
+
+
+

Destination

+
+
+ +
+
+
+
+

Encrypted Backup Password

+
+
+ +
+
+
+
+ + +
+
+
+
+
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + +
+ Snapshot ID + + Date + + Host + + Path + + Actions +
+ + + + + Restore +
+
+
+{% endblock %} diff --git a/IncBackups/urls.py b/IncBackups/urls.py index 831a7476c..a2e7dbfa4 100644 --- a/IncBackups/urls.py +++ b/IncBackups/urls.py @@ -3,8 +3,11 @@ from . import views urlpatterns = [ url(r'^createBackup$', views.create_backup, name='createBackupInc'), + url(r'^V2/createBackupV2$', views.create_backupV2, name='createBackupIncV2'), url(r'^restoreRemoteBackups$', views.restore_remote_backups, name='restoreRemoteBackupsInc'), + url(r'^V2/restoreRemoteBackupsV2$', views.restore_remote_backupsV2, name='restoreRemoteBackupsIncV2'), url(r'^backupDestinations$', views.backup_destinations, name='backupDestinationsInc'), + url(r'^V2/backupDestinationsV2$', views.backup_destinationsV2, name='backupDestinationsIncV2'), url(r'^addDestination$', views.add_destination, name='addDestinationInc'), url(r'^populateCurrentRecords$', views.populate_current_records, name='populateCurrentRecordsInc'), url(r'^removeDestination$', views.remove_destination, name='removeDestinationInc'), @@ -15,6 +18,7 @@ urlpatterns = [ url(r'^fetchRestorePoints$', views.fetch_restore_points, name='fetchRestorePointsInc'), url(r'^restorePoint$', views.restore_point, name='restorePointInc'), url(r'^scheduleBackups$', views.schedule_backups, name='scheduleBackupsInc'), + url(r'^V2/scheduleBackupsV2$', views.schedule_backupsV2, name='scheduleBackupsIncV2'), url(r'^submitBackupSchedule$', views.submit_backup_schedule, name='submitBackupScheduleInc'), url(r'^scheduleDelete$', views.schedule_delete, name='scheduleDeleteInc'), url(r'^getCurrentBackupSchedules$', views.get_current_backup_schedules, name='getCurrentBackupSchedulesInc'), @@ -24,7 +28,9 @@ urlpatterns = [ url(r'^addWebsite$', views.add_website, name='addWebsite'), ### V2 Backups URls url(r'^CreateV2Backup$', views.CreateV2Backup, name='CreateV2Backup'), + url(r'^V2/CreateV2BackupV2$', views.CreateV2BackupV2, name='CreateV2BackupV2'), url(r'^ConfigureV2Backup$', views.ConfigureV2Backup, name='ConfigureV2Backup'), + url(r'^V2/ConfigureV2BackupV2$', views.ConfigureV2BackupV2, name='ConfigureV2BackupV2'), url(r'^ConfigureV2BackupSetup$', views.ConfigureV2BackupSetup, name='ConfigureV2BackupSetup'), url(r'^RestoreV2backupSite$', views.RestoreV2backupSite, name='RestoreV2backupSite'), url(r'^selectwebsiteRetorev2$', views.selectwebsiteRetorev2, name='selectwebsiteRetorev2'), @@ -36,7 +42,8 @@ urlpatterns = [ url(r'^ConfigureSftpV2Backup$', views.ConfigureSftpV2Backup, name='ConfigureSftpV2Backup'), url(r'^schedulev2Backups$', views.schedulev2Backups, name='schedulev2Backups'), + url(r'^V2/schedulev2BackupsV2$', views.schedulev2BackupsV2, name='schedulev2BackupsV2'), url(r'^DeleteScheduleV2$', views.DeleteScheduleV2, name='DeleteScheduleV2'), url(r'^CreateScheduleV2$', views.CreateScheduleV2, name='CreateScheduleV2'), -] \ No newline at end of file +] diff --git a/IncBackups/views.py b/IncBackups/views.py index e1b31b52e..5a17aa5f7 100644 --- a/IncBackups/views.py +++ b/IncBackups/views.py @@ -23,8 +23,6 @@ from .IncBackupsControl import IncJobs from .models import IncJob, BackupJob, JobSites - - def def_renderer(request, templateName, args, context=None): proc = httpProc(request, templateName, args, context) @@ -53,10 +51,7 @@ def _get_user_acl(request): return user_id, current_acl - - def create_backup(request): - try: user_id, current_acl = _get_user_acl(request) if ACLManager.currentContextPermission(current_acl, 'createBackup') == 0: @@ -73,6 +68,23 @@ def create_backup(request): return redirect(loadLoginPage) +def create_backupV2(request): + try: + user_id, current_acl = _get_user_acl(request) + if ACLManager.currentContextPermission(current_acl, 'createBackup') == 0: + return ACLManager.loadError() + + websites = ACLManager.findAllSites(current_acl, user_id) + + destinations = _get_destinations(local=True) + + return def_renderer(request, 'IncBackups/createBackupV2.html', + {'websiteList': websites, 'destinations': destinations}, 'createBackup') + except BaseException as msg: + logging.writeToFile(str(msg)) + return redirect(loadLoginPage) + + def backup_destinations(request): try: user_id, current_acl = _get_user_acl(request) @@ -85,6 +97,18 @@ def backup_destinations(request): return redirect(loadLoginPage) +def backup_destinationsV2(request): + try: + user_id, current_acl = _get_user_acl(request) + if ACLManager.currentContextPermission(current_acl, 'addDeleteDestinations') == 0: + return ACLManager.loadError() + + return def_renderer(request, 'IncBackups/incrementalDestinationsV2.html', {}, 'addDeleteDestinations') + except BaseException as msg: + logging.writeToFile(str(msg)) + return redirect(loadLoginPage) + + def add_destination(request): try: user_id, current_acl = _get_user_acl(request) @@ -219,6 +243,7 @@ def populate_current_records(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) + def remove_destination(request): try: user_id, current_acl = _get_user_acl(request) @@ -246,6 +271,7 @@ def remove_destination(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) + def fetch_current_backups(request): try: user_id, current_acl = _get_user_acl(request) @@ -291,6 +317,7 @@ def fetch_current_backups(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) + def submit_backup_creation(request): try: user_id, current_acl = _get_user_acl(request) @@ -329,6 +356,7 @@ def submit_backup_creation(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) + def get_backup_status(request): try: data = json.loads(request.body) @@ -392,6 +420,7 @@ def get_backup_status(request): logging.writeToFile(str(msg) + " [backupStatus]") return HttpResponse(final_json) + def delete_backup(request): try: @@ -422,6 +451,7 @@ def delete_backup(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) + def fetch_restore_points(request): try: user_id, current_acl = _get_user_acl(request) @@ -456,6 +486,7 @@ def fetch_restore_points(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) + def restore_point(request): try: user_id, current_acl = _get_user_acl(request) @@ -519,6 +550,23 @@ def schedule_backups(request): return redirect(loadLoginPage) +def schedule_backupsV2(request): + try: + user_id, current_acl = _get_user_acl(request) + if ACLManager.currentContextPermission(current_acl, 'scheduleBackups') == 0: + return ACLManager.loadError() + + websites = ACLManager.findAllSites(current_acl, user_id) + + destinations = _get_destinations(local=True) + + return def_renderer(request, 'IncBackups/backupScheduleV2.html', + {'websiteList': websites, 'destinations': destinations}, 'scheduleBackups') + except BaseException as msg: + logging.writeToFile(str(msg)) + return redirect(loadLoginPage) + + def submit_backup_schedule(request): try: user_id, current_acl = _get_user_acl(request) @@ -638,6 +686,23 @@ def restore_remote_backups(request): return redirect(loadLoginPage) +def restore_remote_backupsV2(request): + try: + user_id, current_acl = _get_user_acl(request) + if ACLManager.currentContextPermission(current_acl, 'createBackup') == 0: + return ACLManager.loadError() + + websites = ACLManager.findAllSites(current_acl, user_id) + + destinations = _get_destinations() + + return def_renderer(request, 'IncBackups/restoreRemoteBackupsV2.html', + {'websiteList': websites, 'destinations': destinations}, 'createBackup') + except BaseException as msg: + logging.writeToFile(str(msg)) + return redirect(loadLoginPage) + + def save_changes(request): try: user_id, current_acl = _get_user_acl(request) @@ -712,6 +777,7 @@ def add_website(request): final_json = json.dumps({'status': 0, 'error_message': str(msg)}) return HttpResponse(final_json) + #### Backups v2 def ConfigureV2Backup(request): @@ -729,18 +795,44 @@ def ConfigureV2Backup(request): websites = ACLManager.findAllSites(current_acl, user_id) # # destinations = _get_destinations(local=True) - proc = httpProc(request, 'IncBackups/ConfigureV2Backup.html', {'websiteList': websites, 'BackupStat': BackupStat}) + proc = httpProc(request, 'IncBackups/ConfigureV2Backup.html', + {'websiteList': websites, 'BackupStat': BackupStat}) return proc.render() except BaseException as msg: logging.writeToFile(str(msg)) return redirect(loadLoginPage) + +def ConfigureV2BackupV2(request): + try: + user_id, current_acl = _get_user_acl(request) + + if ACLManager.currentContextPermission(current_acl, 'createBackup') == 0: + return ACLManager.loadError() + + if ACLManager.CheckForPremFeature('all'): + BackupStat = 1 + else: + BackupStat = 0 + + websites = ACLManager.findAllSites(current_acl, user_id) + # + # destinations = _get_destinations(local=True) + proc = httpProc(request, 'IncBackups/ConfigureV2BackupV2.html', + {'websiteList': websites, 'BackupStat': BackupStat}) + return proc.render() + + except BaseException as msg: + logging.writeToFile(str(msg)) + return redirect(loadLoginPage) + + def ConfigureV2BackupSetup(request): try: userID = request.session['userID'] - req_data={} + req_data = {} req_data['name'] = 'GDrive' req_data['token'] = request.GET.get('t') req_data['refresh_token'] = request.GET.get('r') @@ -754,7 +846,6 @@ def ConfigureV2BackupSetup(request): currentACL = ACLManager.loadedACL(userID) admin = Administrator.objects.get(pk=userID) - if ACLManager.checkOwnership(website, admin, currentACL) == 1: pass else: @@ -769,9 +860,10 @@ def ConfigureV2BackupSetup(request): return ConfigureV2Backup(request) except BaseException as msg: - logging.writeToFile("Error configure"+str(msg)) + logging.writeToFile("Error configure" + str(msg)) return redirect(loadLoginPage) + def CreateV2Backup(request): try: userID = request.session['userID'] @@ -780,6 +872,16 @@ def CreateV2Backup(request): except KeyError: return redirect(loadLoginPage) + +def CreateV2BackupV2(request): + try: + userID = request.session['userID'] + bm = BackupManager() + return bm.CreateV2backupSiteV2(request, userID) + except KeyError: + return redirect(loadLoginPage) + + def CreateV2BackupButton(request): try: userID = request.session['userID'] @@ -787,7 +889,6 @@ def CreateV2BackupButton(request): Selectedwebsite = data['Selectedwebsite'] Selectedrepo = data['Selectedrepo'] - currentACL = ACLManager.loadedACL(userID) admin = Administrator.objects.get(pk=userID) @@ -796,7 +897,6 @@ def CreateV2BackupButton(request): else: return ACLManager.loadError() - extra_args = {} extra_args['function'] = 'InitiateBackup' extra_args['website'] = Selectedwebsite @@ -816,7 +916,7 @@ def CreateV2BackupButton(request): time.sleep(2) - data_ret = {'status': 1, 'installStatus': 1, 'error_message': 'None',} + data_ret = {'status': 1, 'installStatus': 1, 'error_message': 'None', } json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -825,6 +925,7 @@ def CreateV2BackupButton(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) + def CreateV2BackupStatus(request): try: userID = request.session['userID'] @@ -833,6 +934,7 @@ def CreateV2BackupStatus(request): except KeyError: return redirect(loadLoginPage) + def RestoreV2backupSite(request): try: userID = request.session['userID'] @@ -841,6 +943,7 @@ def RestoreV2backupSite(request): except KeyError: return redirect(loadLoginPage) + def RestorePathV2(request): try: userID = request.session['userID'] @@ -870,14 +973,13 @@ def RestorePathV2(request): # extra_args['BackupEmails'] = data['websiteEmails'] if 'websiteEmails' in data else False # extra_args['BackupDatabase'] = data['websiteDatabases'] if 'websiteDatabases' in data else False - background = CPBackupsV2(extra_args) background.start() # vm = CPBackupsV2({'domain': Selectedwebsite, 'BackendName': Selectedrepo, "function": "", 'BasePath': '/home/backup'}) # status = vm.InitiateRestore(SnapShotId, Path) - data_ret = {'status': 1, 'installStatus': 1, 'error_message': 'None',} + data_ret = {'status': 1, 'installStatus': 1, 'error_message': 'None', } json_data = json.dumps(data_ret) return HttpResponse(json_data) @@ -886,6 +988,7 @@ def RestorePathV2(request): json_data = json.dumps(data_ret) return HttpResponse(json_data) + def selectwebsiteRetorev2(request): import re try: @@ -901,11 +1004,11 @@ def selectwebsiteRetorev2(request): else: return ACLManager.loadError() - obj = Websites.objects.get(domain = str(Selectedwebsite)) - #/home/cyberpanel.net/.config/rclone/rclone.conf - path = '/home/%s/.config/rclone/rclone.conf' %(obj.domain) + obj = Websites.objects.get(domain=str(Selectedwebsite)) + # /home/cyberpanel.net/.config/rclone/rclone.conf + path = '/home/%s/.config/rclone/rclone.conf' % (obj.domain) - command = 'cat %s'%(path) + command = 'cat %s' % (path) result = pu.outputExecutioner(command) if result.find('type') > -1: @@ -917,7 +1020,6 @@ def selectwebsiteRetorev2(request): final_json = json.dumps({'status': 0, 'fetchStatus': 0, 'error_message': 'Could not Find repo'}) return HttpResponse(final_json) - # final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": 1}) # return HttpResponse(final_json) except BaseException as msg: @@ -925,6 +1027,7 @@ def selectwebsiteRetorev2(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) + def ConfigureSftpV2Backup(request): try: userID = request.session['userID'] @@ -949,7 +1052,6 @@ def ConfigureSftpV2Backup(request): req_data['password'] = sfptpasswd req_data['Repo_Name'] = Repo_Name - cpbuv2 = CPBackupsV2( {'domain': Selectedwebsite, 'BasePath': '/home/backup', 'BackupDatabase': 1, 'BackupData': 1, 'BackupEmails': 1, 'BackendName': 'SFTP', 'function': None}) @@ -967,6 +1069,7 @@ def ConfigureSftpV2Backup(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) + def selectwebsiteCreatev2(request): import re try: @@ -982,16 +1085,15 @@ def selectwebsiteCreatev2(request): else: return ACLManager.loadError() - obj = Websites.objects.get(domain = str(Selectedwebsite)) - #/home/cyberpanel.net/.config/rclone/rclone.conf - path = '/home/%s/.config/rclone/rclone.conf' %(obj.domain) + obj = Websites.objects.get(domain=str(Selectedwebsite)) + # /home/cyberpanel.net/.config/rclone/rclone.conf + path = '/home/%s/.config/rclone/rclone.conf' % (obj.domain) - command = 'cat %s'%(path) + command = 'cat %s' % (path) CurrentContent = pu.outputExecutioner(command) status, currentSchedules = CPBackupsV2.FetchCurrentSchedules(str(Selectedwebsite)) - if CurrentContent.find('No such file or directory') > -1: LocalRclonePath = f'/home/{obj.domain}/.config/rclone' command = f'mkdir -p {LocalRclonePath}' @@ -1010,7 +1112,8 @@ def selectwebsiteCreatev2(request): if result.find('type') > -1: pattern = r'\[(.*?)\]' matches = re.findall(pattern, result) - final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": matches, 'currentSchedules': currentSchedules}) + final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": matches, + 'currentSchedules': currentSchedules}) return HttpResponse(final_json) else: final_json = json.dumps({'status': 0, 'fetchStatus': 0, 'error_message': 'Could not Find repo'}) @@ -1022,13 +1125,14 @@ def selectwebsiteCreatev2(request): if result.find('type') > -1: pattern = r'\[(.*?)\]' matches = re.findall(pattern, result) - final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": matches, 'currentSchedules': currentSchedules}) + final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": matches, + 'currentSchedules': currentSchedules}) return HttpResponse(final_json) else: - final_json = json.dumps({'status': 0, 'fetchStatus': 0, 'error_message': 'Could not Find repo', 'currentSchedules': currentSchedules}) + final_json = json.dumps({'status': 0, 'fetchStatus': 0, 'error_message': 'Could not Find repo', + 'currentSchedules': currentSchedules}) return HttpResponse(final_json) - # logging.writeToFile(str(CurrentContent)) # final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": None}) # return HttpResponse(final_json) @@ -1040,12 +1144,13 @@ def selectwebsiteCreatev2(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) + def selectreporestorev2(request): try: userID = request.session['userID'] data = json.loads(request.body) Selectedrepo = data['Selectedrepo'] - Selectedwebsite= data['Selectedwebsite'] + Selectedwebsite = data['Selectedwebsite'] currentACL = ACLManager.loadedACL(userID) admin = Administrator.objects.get(pk=userID) @@ -1054,12 +1159,11 @@ def selectreporestorev2(request): else: return ACLManager.loadError() - # f'rustic -r testremote snapshots --password "" --json 2>/dev/null' # final_json = json.dumps({'status': 0, 'fetchStatus': 1, 'error_message': Selectedrepo }) # return HttpResponse(final_json) - vm = CPBackupsV2({'domain': Selectedwebsite, 'BackendName': Selectedrepo, "function":""}) + vm = CPBackupsV2({'domain': Selectedwebsite, 'BackendName': Selectedrepo, "function": ""}) status, data = vm.FetchSnapShots() if status == 1: @@ -1067,7 +1171,7 @@ def selectreporestorev2(request): return HttpResponse(final_json) else: # final_json = json.dumps({'status': 0, 'fetchStatus': 1, 'error_message': ac,}) - final_json = json.dumps({'status': 0, 'fetchStatus': 1, 'error_message': 'Cannot Find!',}) + final_json = json.dumps({'status': 0, 'fetchStatus': 1, 'error_message': 'Cannot Find!', }) return HttpResponse(final_json) @@ -1076,6 +1180,7 @@ def selectreporestorev2(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) + def schedulev2Backups(request): try: userID = request.session['userID'] @@ -1084,6 +1189,16 @@ def schedulev2Backups(request): except KeyError: return redirect(loadLoginPage) + +def schedulev2BackupsV2(request): + try: + userID = request.session['userID'] + bm = BackupManager() + return bm.schedulev2BackupsV2(request, userID) + except KeyError: + return redirect(loadLoginPage) + + def DeleteScheduleV2(request): try: userID = request.session['userID'] @@ -1103,8 +1218,8 @@ def DeleteScheduleV2(request): else: return ACLManager.loadError() - - status, message = CPBackupsV2.DeleteSchedule(Selectedwebsite, repo, frequency, websiteData, websiteDatabases, websiteEmails) + status, message = CPBackupsV2.DeleteSchedule(Selectedwebsite, repo, frequency, websiteData, websiteDatabases, + websiteEmails) final_dic = {'status': 1, 'error_message': message} final_json = json.dumps(final_dic) @@ -1119,6 +1234,7 @@ def DeleteScheduleV2(request): final_json = json.dumps(final_dic) return HttpResponse(final_json) + def CreateScheduleV2(request): try: userID = request.session['userID'] @@ -1144,8 +1260,8 @@ def CreateScheduleV2(request): else: return ACLManager.loadError() - - status, message = CPBackupsV2.CreateScheduleV2(Selectedwebsite, repo, frequency, websiteData, websiteDatabases, websiteEmails, retention) + status, message = CPBackupsV2.CreateScheduleV2(Selectedwebsite, repo, frequency, websiteData, websiteDatabases, + websiteEmails, retention) final_dic = {'status': 1, 'error_message': message} final_json = json.dumps(final_dic) @@ -1158,4 +1274,4 @@ def CreateScheduleV2(request): except BaseException as msg: final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)} final_json = json.dumps(final_dic) - return HttpResponse(final_json) \ No newline at end of file + return HttpResponse(final_json) diff --git a/backup/backupManager.py b/backup/backupManager.py index 78e50d573..2914681d7 100755 --- a/backup/backupManager.py +++ b/backup/backupManager.py @@ -84,6 +84,12 @@ class BackupManager: proc = httpProc(request, 'IncBackups/CreateV2Backup.html', {'websiteList': websitesName}, 'createBackup') return proc.render() + def CreateV2backupSiteV2(self, request=None, userID=None, data=None): + currentACL = ACLManager.loadedACL(userID) + websitesName = ACLManager.findAllSites(currentACL, userID) + proc = httpProc(request, 'IncBackups/CreateV2BackupV2.html', {'websiteList': websitesName}, 'createBackup') + return proc.render() + def schedulev2Backups(self, request=None, userID=None, data=None): if ACLManager.CheckForPremFeature('all'): @@ -97,6 +103,19 @@ class BackupManager: {'websiteList': websitesName, "BackupStat": BackupStat}, 'createBackup') return proc.render() + def schedulev2BackupsV2(self, request=None, userID=None, data=None): + + if ACLManager.CheckForPremFeature('all'): + BackupStat = 1 + else: + BackupStat = 0 + + currentACL = ACLManager.loadedACL(userID) + websitesName = ACLManager.findAllSites(currentACL, userID) + proc = httpProc(request, 'IncBackups/ScheduleV2BackupV2.html', + {'websiteList': websitesName, "BackupStat": BackupStat}, 'createBackup') + return proc.render() + def gDrive(self, request=None, userID=None, data=None): currentACL = ACLManager.loadedACL(userID) admin = Administrator.objects.get(pk=userID) @@ -109,6 +128,18 @@ class BackupManager: 'createBackup') return proc.render() + def gDriveV2(self, request=None, userID=None, data=None): + currentACL = ACLManager.loadedACL(userID) + admin = Administrator.objects.get(pk=userID) + gDriveAcctsList = [] + gDriveAccts = admin.gdrive_set.all() + for items in gDriveAccts: + gDriveAcctsList.append(items.name) + websitesName = ACLManager.findAllSites(currentACL, userID) + proc = httpProc(request, 'backup/googleDriveV2.html', {'accounts': gDriveAcctsList, 'websites': websitesName}, + 'createBackup') + return proc.render() + def gDriveSetup(self, userID=None, request=None): try: currentACL = ACLManager.loadedACL(userID) @@ -779,6 +810,10 @@ class BackupManager: proc = httpProc(request, 'backup/backupDestinations.html', {}, 'addDeleteDestinations') return proc.render() + def backupDestinationsV2(self, request=None, userID=None, data=None): + proc = httpProc(request, 'backup/backupDestinationsV2.html', {}, 'addDeleteDestinations') + return proc.render() + def submitDestinationCreation(self, userID=None, data=None): try: currentACL = ACLManager.loadedACL(userID) @@ -951,6 +986,17 @@ class BackupManager: 'scheduleBackups') return proc.render() + def scheduleBackupV2(self, request, userID=None, data=None): + currentACL = ACLManager.loadedACL(userID) + destinations = NormalBackupDests.objects.all() + dests = [] + for dest in destinations: + dests.append(dest.name) + websitesName = ACLManager.findAllSites(currentACL, userID) + proc = httpProc(request, 'backup/backupScheduleV2.html', {'destinations': dests, 'websites': websitesName}, + 'scheduleBackups') + return proc.render() + def getCurrentBackupSchedules(self, userID=None, data=None): try: currentACL = ACLManager.loadedACL(userID) @@ -1077,6 +1123,10 @@ class BackupManager: proc = httpProc(request, 'backup/remoteBackups.html', None, 'remoteBackups') return proc.render() + def remoteBackupsV2(self, request, userID=None, data=None): + proc = httpProc(request, 'backup/remoteBackupsV2.html', None, 'remoteBackups') + return proc.render() + def submitRemoteBackups(self, userID=None, data=None): try: currentACL = ACLManager.loadedACL(userID) diff --git a/backup/static/backup/backupV2.js b/backup/static/backup/backupV2.js index e1885b6a6..a2c819cdd 100644 --- a/backup/static/backup/backupV2.js +++ b/backup/static/backup/backupV2.js @@ -412,4 +412,1546 @@ newapp.controller('restoreWebsiteControlV2', function ($scope, $http, $timeout) }; +}); +newapp.controller('backupDestinationsV2', function ($scope, $http) { + $scope.cyberpanelLoading = true; + $scope.sftpHide = true; + $scope.localHide = true; + + $scope.fetchDetails = function () { + + if ($scope.destinationType === 'SFTP') { + $scope.sftpHide = false; + $scope.localHide = true; + $scope.populateCurrentRecords(); + } else { + $scope.sftpHide = true; + $scope.localHide = false; + $scope.populateCurrentRecords(); + } + }; + + $scope.populateCurrentRecords = function () { + + $scope.cyberpanelLoading = false; + + url = "/backup/getCurrentBackupDestinations"; + + var type = 'SFTP'; + if ($scope.destinationType === 'SFTP') { + type = 'SFTP'; + } else { + type = 'local'; + } + + var data = { + type: type + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + $scope.records = JSON.parse(response.data.data); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + }; + + $scope.addDestination = function (type) { + $scope.cyberpanelLoading = false; + + url = "/backup/submitDestinationCreation"; + + if (type === 'SFTP') { + var data = { + type: type, + name: $scope.name, + IPAddress: $scope.IPAddress, + userName: $scope.userName, + password: $scope.password, + backupSSHPort: $scope.backupSSHPort, + path: $scope.path + }; + } else { + var data = { + type: type, + path: $scope.localPath, + name: $scope.name + }; + } + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberpanelLoading = true; + $scope.populateCurrentRecords(); + if (response.data.status === 1) { + new PNotify({ + title: 'Success!', + text: 'Destination successfully added.', + type: 'success' + }); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + }; + + $scope.removeDestination = function (type, nameOrPath) { + $scope.cyberpanelLoading = false; + + + url = "/backup/deleteDestination"; + + var data = { + type: type, + nameOrPath: nameOrPath, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberpanelLoading = true; + $scope.populateCurrentRecords(); + if (response.data.status === 1) { + new PNotify({ + title: 'Success!', + text: 'Destination successfully removed.', + type: 'success' + }); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialDatas(response) { + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + }; + + +}); +newapp.controller('remoteBackupControlV2', function ($scope, $http, $timeout) { + + $scope.backupButton = true; + $scope.backupLoading = true; + $scope.request = true; + $scope.requestData = ""; + $scope.submitDisable = false; + $scope.startRestore = true; + + $scope.accountsInRemoteServerTable = true; + $scope.transferBoxBtn = true; + $scope.stopTransferbtn = true; + $scope.fetchAccountsBtn = false; + + + // notifications boxes + $scope.notificationsBox = true; + $scope.errorMessage = true; + $scope.couldNotConnect = true; + $scope.accountsFetched = true; + $scope.backupProcessStarted = true; + $scope.backupCancelled = true; + + // status box + + $scope.backupStatus = true; + + var websitesToBeBacked = []; + var websitesToBeBackedTemp = []; + + var index = 0; + var tempTransferDir = ""; + + $scope.passwordEnter = function () { + $scope.backupButton = false; + }; + + $scope.addRemoveWebsite = function (website, websiteStatus) { + + if (websiteStatus === true) { + var check = 1; + for (var j = 0; j < websitesToBeBacked.length; j++) { + if (websitesToBeBacked[j] == website) { + check = 0; + break; + } + } + if (check == 1) { + websitesToBeBacked.push(website); + } + + } else { + + var tempArray = []; + + for (var j = 0; j < websitesToBeBacked.length; j++) { + if (websitesToBeBacked[j] != website) { + tempArray.push(websitesToBeBacked[j]); + } + } + websitesToBeBacked = tempArray; + } + }; + + $scope.allChecked = function (webSiteStatus) { + + if (webSiteStatus === true) { + + websitesToBeBacked = websitesToBeBackedTemp; + $scope.webSiteStatus = true; + } else { + websitesToBeBacked = []; + $scope.webSiteStatus = false; + } + }; + + $scope.fetchAccountsFromRemoteServer = function () { + + $scope.backupLoading = false; + + // notifications boxes + $scope.notificationsBox = true; + $scope.errorMessage = true; + $scope.couldNotConnect = true; + $scope.accountsFetched = true; + $scope.backupProcessStarted = true; + $scope.backupCancelled = true; + + var IPAddress = $scope.IPAddress; + var password = $scope.password; + + url = "/backup/submitRemoteBackups"; + + var data = { + ipAddress: IPAddress, + password: password, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + + if (response.data.status === 1) { + $scope.records = JSON.parse(response.data.data); + var parsed = JSON.parse(response.data.data); + + for (var j = 0; j < parsed.length; j++) { + websitesToBeBackedTemp.push(parsed[j].website); + } + + $scope.accountsInRemoteServerTable = false; + $scope.backupLoading = true; + + // enable the transfer/cancel btn + + $scope.transferBoxBtn = false; + + // notifications boxes + $scope.notificationsBox = false; + $scope.errorMessage = true; + $scope.couldNotConnect = true; + $scope.accountsFetched = false; + $scope.backupProcessStarted = true; + $scope.backupCancelled = true; + + + } else { + $scope.error_message = response.data.error_message; + $scope.backupLoading = true; + + // notifications boxes + $scope.notificationsBox = false; + $scope.errorMessage = false; + $scope.couldNotConnect = true; + $scope.accountsFetched = true; + $scope.backupProcessStarted = true; + $scope.backupCancelled = true; + } + + } + + function cantLoadInitialDatas(response) { + + // notifications boxes + + $scope.notificationsBox = false; + $scope.errorMessage = true; + $scope.couldNotConnect = false; + $scope.accountsFetched = true; + $scope.backupProcessStarted = true; + $scope.backupCancelled = true; + + } + + }; + + $scope.startTransfer = function () { + + // notifications boxes + $scope.notificationsBox = true; + $scope.errorMessage = true; + $scope.couldNotConnect = true; + $scope.accountsFetched = true; + $scope.backupProcessStarted = true; + $scope.backupCancelled = true; + + + if (websitesToBeBacked.length === 0) { + alert("No websites selected for transfer."); + return; + } + + // disable fetch accounts button + + $scope.fetchAccountsBtn = true; + $scope.backupLoading = false; + + var IPAddress = $scope.IPAddress; + var password = $scope.password; + + url = "/backup/starRemoteTransfer"; + + var data = { + ipAddress: IPAddress, + password: password, + accountsToTransfer: websitesToBeBacked, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + + if (response.data.remoteTransferStatus === 1) { + tempTransferDir = response.data.dir; + $scope.accountsInRemoteServerTable = true; + + // notifications boxes + $scope.notificationsBox = false; + $scope.errorMessage = true; + $scope.couldNotConnect = true; + $scope.accountsFetched = true; + $scope.backupProcessStarted = false; + $scope.backupCancelled = true; + + // disable transfer button + + $scope.startTransferbtn = true; + + + // enable cancel button + + $scope.stopTransferbtn = false; + + + getBackupStatus(); + + + } else { + + $scope.error_message = response.data.error_message; + $scope.backupLoading = true; + + // Notifications box settings + + // notifications boxes + $scope.notificationsBox = false; + $scope.errorMessage = false; + $scope.couldNotConnect = true; + $scope.accountsFetched = true; + $scope.backupProcessStarted = true; + $scope.backupCancelled = true; + + } + + } + + function cantLoadInitialDatas(response) { + + // Notifications box settings + + // notifications boxes + $scope.notificationsBox = false; + $scope.errorMessage = true; + $scope.couldNotConnect = false; + $scope.accountsFetched = true; + $scope.backupProcessStarted = true; + $scope.backupCancelled = true; + + } + + }; + + function getBackupStatus(password) { + + url = "/backup/getRemoteTransferStatus"; + + var data = { + password: $scope.password, + ipAddress: $scope.IPAddress, + dir: tempTransferDir + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + + if (response.data.remoteTransferStatus === 1) { + + if (response.data.backupsSent === 0) { + $scope.backupStatus = false; + $scope.requestData = response.data.status; + $timeout(getBackupStatus, 2000); + } else { + $scope.requestData = response.data.status; + $timeout.cancel(); + + // Start the restore of remote backups that are transferred to local server + + remoteBackupRestore(); + } + } else { + + $scope.error_message = response.data.error_message; + $scope.backupLoading = true; + $scope.couldNotConnect = true; + + // Notifications box settings + + $scope.couldNotConnect = true; + $scope.errorMessage = false; + $scope.accountsFetched = true; + $scope.notificationsBox = false; + $timeout.cancel(); + + } + + } + + function cantLoadInitialDatas(response) { + // Notifications box settings + + $scope.couldNotConnect = false; + $scope.errorMessage = true; + $scope.accountsFetched = true; + $scope.notificationsBox = false; + } + }; + + function remoteBackupRestore() { + url = "/backup/remoteBackupRestore"; + + var data = { + backupDir: tempTransferDir, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + + if (response.data.remoteRestoreStatus === 1) { + localRestoreStatus(); + } + } + + function cantLoadInitialDatas(response) { + // Notifications box settings + + $scope.couldNotConnect = false; + $scope.errorMessage = true; + $scope.accountsFetched = true; + $scope.notificationsBox = false; + $scope.backupLoading = true; + } + + /////////////// + + }; + + function localRestoreStatus(password) { + + + url = "/backup/localRestoreStatus"; + + var data = { + backupDir: tempTransferDir, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + $scope.backupProcessStarted = true; + + if (response.data.remoteTransferStatus === 1) { + + if (response.data.complete === 0) { + $scope.backupStatus = false; + $scope.restoreData = response.data.status; + $timeout(localRestoreStatus, 2000); + } else { + $scope.restoreData = response.data.status; + $timeout.cancel(); + $scope.backupLoading = true; + $scope.startTransferbtn = false; + } + } else { + + $scope.error_message = response.data.error_message; + $scope.backupLoading = true; + $scope.couldNotConnect = true; + + // Notifications box settings + + $scope.couldNotConnect = true; + $scope.errorMessage = false; + $scope.accountsFetched = true; + $scope.notificationsBox = false; + + } + + } + + function cantLoadInitialDatas(response) { + // Notifications box settings + + $scope.couldNotConnect = false; + $scope.errorMessage = true; + $scope.accountsFetched = true; + $scope.notificationsBox = false; + } + }; + + + function restoreAccounts() { + + url = "/backup/getRemoteTransferStatus"; + + var data = { + password: $scope.password, + ipAddress: $scope.IPAddress, + dir: tempTransferDir, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + + if (response.data.remoteTransferStatus == 1) { + + if (response.data.backupsSent == 0) { + $scope.backupStatus = false; + $scope.requestData = response.data.status; + $timeout(getBackupStatus, 2000); + } else { + $timeout.cancel(); + } + } + + } + + function cantLoadInitialDatas(response) { + // Notifications box settings + + $scope.couldNotConnect = false; + $scope.errorMessage = true; + $scope.accountsFetched = true; + $scope.notificationsBox = false; + } + }; + + $scope.cancelRemoteBackup = function () { + + + $scope.backupLoading = false; + + // notifications boxes + $scope.notificationsBox = true; + $scope.errorMessage = true; + $scope.couldNotConnect = true; + $scope.accountsFetched = true; + $scope.backupProcessStarted = true; + $scope.backupCancelled = true; + + var IPAddress = $scope.IPAddress; + var password = $scope.password; + + url = "/backup/cancelRemoteBackup"; + + var data = { + ipAddress: IPAddress, + password: password, + dir: tempTransferDir, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + + if (response.data.cancelStatus == 1) { + $scope.backupLoading = true; + + // notifications boxes + $scope.notificationsBox = false; + $scope.errorMessage = true; + $scope.couldNotConnect = true; + $scope.accountsFetched = true; + $scope.backupProcessStarted = true; + $scope.backupCancelled = false; + + // enable transfer button + + $scope.startTransferbtn = false; + + //disable cancel button + + $scope.stopTransferbtn = true; + + // hide status box + + $scope.backupStatus = true; + + // bring back websites table + + $scope.accountsInRemoteServerTable = false; + + // enable fetch button + + $scope.fetchAccountsBtn = false; + + + } else { + + $scope.error_message = response.data.error_message; + $scope.backupLoading = true; + + // notifications boxes + + $scope.notificationsBox = false; + $scope.errorMessage = false; + $scope.couldNotConnect = true; + $scope.accountsFetched = true; + $scope.backupProcessStarted = true; + $scope.backupCancelled = true; + + + } + + } + + function cantLoadInitialDatas(response) { + + // notifications boxes + + $scope.notificationsBox = false; + $scope.errorMessage = true; + $scope.couldNotConnect = false; + $scope.accountsFetched = true; + $scope.backupProcessStarted = true; + $scope.backupCancelled = true; + + } + + }; + + +}); +newapp.controller('scheduleBackupV2', function ($scope, $http, $window) { + + $scope.cyberPanelLoading = true; + $scope.driveHidden = true; + $scope.jobsHidden = true; + + $scope.currentPage = 1; + $scope.recordsToShow = 10; + + $scope.fetchJobs = function () { + + $scope.cyberPanelLoading = false; + $scope.jobsHidden = true; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + var data = { + selectedAccount: $scope.selectedAccount, + }; + + + dataurl = "/backup/fetchNormalJobs"; + + $http.post(dataurl, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + if (response.data.status === 1) { + $scope.jobsHidden = false; + new PNotify({ + title: 'Success', + text: 'Successfully fetched.', + type: 'success' + }); + $scope.jobs = response.data.jobs; + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + + + } + + }; + + $scope.addSchedule = function () { + $scope.cyberPanelLoading = false; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + var data = { + selectedAccount: $scope.selectedAccountAdd, + name: $scope.name, + backupFrequency: $scope.backupFrequency, + backupRetention: $scope.backupRetention, + }; + + dataurl = "/backup/submitBackupSchedule"; + + $http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData); + + + function ListInitialData(response) { + $scope.cyberPanelLoading = true; + if (response.data.status === 1) { + new PNotify({ + title: 'Success', + text: 'Schedule successfully added.', + type: 'success' + }); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialData(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + + }; + + $scope.fetchWebsites = function () { + + $scope.cyberPanelLoading = false; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + var data = { + selectedAccount: $scope.selectedJob, + page: $scope.currentPage, + recordsToShow: $scope.recordsToShow + }; + + + dataurl = "/backup/fetchgNormalSites"; + + $http.post(dataurl, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + if (response.data.status === 1) { + $scope.driveHidden = false; + new PNotify({ + title: 'Success', + text: 'Successfully fetched.', + type: 'success' + }); + $scope.websites = JSON.parse(response.data.websites); + $scope.pagination = response.data.pagination; + $scope.currently = response.data.currently; + $scope.allSites = response.data.allSites; + $scope.lastRun = response.data.lastRun; + $scope.currentStatus = response.data.currentStatus; + + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + + + } + + }; + + $scope.addSite = function (type) { + $scope.cyberPanelLoading = false; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + var data = { + selectedWebsite: $scope.selectedWebsite, + selectedJob: $scope.selectedJob, + type: type + }; + + dataurl = "/backup/addSiteNormal"; + + $http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData); + + + function ListInitialData(response) { + $scope.cyberPanelLoading = true; + if (response.data.status === 1) { + new PNotify({ + title: 'Success', + text: 'Site successfully added.', + type: 'success' + }); + $scope.fetchWebsites(); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialData(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + + }; + + $scope.deleteAccount = function () { + $scope.cyberPanelLoading = false; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + var data = { + selectedJob: $scope.selectedJob + }; + + dataurl = "/backup/deleteAccountNormal"; + + $http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData); + + + function ListInitialData(response) { + $scope.cyberPanelLoading = true; + if (response.data.status === 1) { + new PNotify({ + title: 'Success', + text: 'Account successfully deleted.', + type: 'success' + }); + location.reload(); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialData(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + + }; + + $scope.changeFrequency = function () { + $scope.cyberPanelLoading = false; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + var data = { + selectedJob: $scope.selectedJob, + backupFrequency: $scope.backupFrequency, + backupRetention: $scope.backupRetention, + }; + + dataurl = "/backup/changeAccountFrequencyNormal"; + + $http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData); + + + function ListInitialData(response) { + $scope.cyberPanelLoading = true; + if (response.data.status === 1) { + new PNotify({ + title: 'Success', + text: 'Changes successfully applied', + type: 'success' + }); + $scope.fetchWebsites(); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialData(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + + }; + + $scope.deleteSite = function (website) { + $scope.cyberPanelLoading = false; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + var data = { + selectedJob: $scope.selectedJob, + website: website + }; + + dataurl = "/backup/deleteSiteNormal"; + + $http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData); + + + function ListInitialData(response) { + $scope.cyberPanelLoading = true; + if (response.data.status === 1) { + new PNotify({ + title: 'Success', + text: 'Website Deleted.', + type: 'success' + }); + $scope.fetchWebsites(); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialData(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + + }; + + $scope.currentPageLogs = 1; + $scope.recordsToShowLogs = 10; + + $scope.fetchLogs = function () { + + $scope.cyberPanelLoading = false; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + var data = { + selectedJob: $scope.selectedJob, + page: $scope.currentPageLogs, + recordsToShow: $scope.recordsToShowLogs + }; + + + dataurl = "/backup/fetchNormalLogs"; + + $http.post(dataurl, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + if (response.data.status === 1) { + $scope.driveHidden = false; + new PNotify({ + title: 'Success', + text: 'Successfully fetched.', + type: 'success' + }); + $scope.logs = JSON.parse(response.data.logs); + $scope.paginationLogs = response.data.pagination; + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + + } + + }; + +}); +newapp.controller('googleDriveV2', function ($scope, $http) { + + $scope.cyberPanelLoading = true; + $scope.driveHidden = true; + + $scope.setupAccount = function(){ + window.open("https://platform.cyberpersons.com/gDrive?name=" + $scope.accountName + '&server=' + window.location.href + 'Setup'); + }; + + $scope.currentPage = 1; + $scope.recordsToShow = 10; + + $scope.fetchWebsites = function () { + + $scope.cyberPanelLoading = false; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + var data = { + selectedAccount: $scope.selectedAccount, + page: $scope.currentPage, + recordsToShow: $scope.recordsToShow + }; + + + dataurl = "/backup/fetchgDriveSites"; + + $http.post(dataurl, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + if (response.data.status === 1) { + $scope.driveHidden = false; + $('#checkret').show() + new PNotify({ + title: 'Success', + text: 'Successfully fetched.', + type: 'success' + }); + $scope.websites = JSON.parse(response.data.websites); + $scope.pagination = response.data.pagination; + $scope.currently = response.data.currently; + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + + + } + + }; + + $scope.addSite = function () { + $scope.cyberPanelLoading = false; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + var data = { + selectedWebsite: $scope.selectedWebsite, + selectedAccount: $scope.selectedAccount + }; + + dataurl = "/backup/addSitegDrive"; + + $http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData); + + + function ListInitialData(response) { + $scope.cyberPanelLoading = true; + if (response.data.status === 1) { + new PNotify({ + title: 'Success', + text: 'Site successfully added.', + type: 'success' + }); + $scope.fetchWebsites(); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialData(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + + }; + + $scope.deleteAccount = function () { + $scope.cyberPanelLoading = false; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + var data = { + selectedAccount: $scope.selectedAccount + }; + + dataurl = "/backup/deleteAccountgDrive"; + + $http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData); + + + function ListInitialData(response) { + $scope.cyberPanelLoading = true; + if (response.data.status === 1) { + new PNotify({ + title: 'Success', + text: 'Account successfully deleted.', + type: 'success' + }); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialData(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + + }; + + $scope.changeRetention = function () { + $scope.cyberPanelLoading = false; + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + var data = { + Retentiontime: $scope.Retentiontime, + selectedAccount: $scope.selectedAccount, + }; + dataurl = "/backup/changeFileRetention"; + + + //console.log(data) + + $http.post(dataurl, data, config).then(fileretention, cantLoadInitialData); + + function fileretention(response) { + $scope.cyberPanelLoading = true; + if (response.data.status === 1) { + new PNotify({ + title: 'Success', + text: 'Changes successfully applied', + type: 'success' + }); + $scope.fetchWebsites(); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + function cantLoadInitialData(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + }; + + + $scope.changeFrequency = function () { + $scope.cyberPanelLoading = false; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + var data = { + selectedAccount: $scope.selectedAccount, + backupFrequency: $scope.backupFrequency, + backupRetention: $scope.backupRetention, + }; + + dataurl = "/backup/changeAccountFrequencygDrive"; + + $http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData); + + + function ListInitialData(response) { + $scope.cyberPanelLoading = true; + if (response.data.status === 1) { + new PNotify({ + title: 'Success', + text: 'Changes successfully applied', + type: 'success' + }); + $scope.fetchWebsites(); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialData(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + + }; + + $scope.deleteSite = function (website) { + $scope.cyberPanelLoading = false; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + var data = { + selectedAccount: $scope.selectedAccount, + website: website + }; + + dataurl = "/backup/deleteSitegDrive"; + + $http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData); + + + function ListInitialData(response) { + $scope.cyberPanelLoading = true; + if (response.data.status === 1) { + new PNotify({ + title: 'Success', + text: 'Website Deleted.', + type: 'success' + }); + $scope.fetchWebsites(); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialData(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + } + + + }; + + $scope.currentPageLogs = 1; + $scope.recordsToShowLogs = 10; + + $scope.fetchLogs = function () { + + $scope.cyberPanelLoading = false; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + var data = { + selectedAccount: $scope.selectedAccount, + page: $scope.currentPageLogs, + recordsToShow: $scope.recordsToShowLogs + }; + + + dataurl = "/backup/fetchDriveLogs"; + + $http.post(dataurl, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + if (response.data.status === 1) { + $scope.driveHidden = false; + new PNotify({ + title: 'Success', + text: 'Successfully fetched.', + type: 'success' + }); + $scope.logs = JSON.parse(response.data.logs); + $scope.paginationLogs = response.data.pagination; + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + + } + + }; + }); \ No newline at end of file diff --git a/backup/templates/backup/backupDestinationsV2.html b/backup/templates/backup/backupDestinationsV2.html new file mode 100644 index 000000000..2b2ed29fc --- /dev/null +++ b/backup/templates/backup/backupDestinationsV2.html @@ -0,0 +1,194 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + +
+
+
+

Set up Backup Destinations -

+ {% trans "Remote Backups" %} +
+
+

On this page you can set up your Backup destinations. (SFTP) +

+
+

Set up Backup Destinations.

+ +
+
+
+
+

Select Type

+
+
+ +
+
+
+
+

Name

+
+
+ +
+
+
+
+

IP Address

+
+
+ +
+
+
+
+

Username

+
+
+ +
+
+
+
+

Password

+
+
+ +
+
+
+
+

Port

+
+
+ +
+
+
+
+

Path

+
+
+ +
+
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + +
+ Name + + IP + + Username + + Path + + Port + + Delete +
+ + + + + + +
+
+
+
+

Name

+
+
+ +
+
+
+
+

Local Path

+
+
+ +
+
+
+ +
+
+
+ + + + + + + + + + + + + + + +
+ Name + + Path + + Delete +
+ + + +
+
+
+{% endblock %} diff --git a/backup/templates/backup/backupScheduleV2.html b/backup/templates/backup/backupScheduleV2.html new file mode 100644 index 000000000..8efc76810 --- /dev/null +++ b/backup/templates/backup/backupScheduleV2.html @@ -0,0 +1,299 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + +
+
+
+

Schedule Backup -

+ {% trans "Remote Backups" %} +
+
+

On this page you can schedule Backups to localhost or remote + server (If you have added one)

+
+

Create New Backup Schedule

+ cyberPanelLoading +
+
+
+
+

Select Destination

+
+
+ +
+
+
+
+

Name

+
+
+ +
+
+
+
+

Select Backup Frequency

+
+
+ +
+
+
+
+

Select Backup Retention. Leave 0 for no limit

+
+
+ +
+
+
+ +
+
+

Manage Existing Backup Schedules

+ cyberPanelLoading +
+
+
+
+

Select Destination

+
+
+ +
+
+
+
+

Select Job

+
+
+ +
+
+ +
+
+
+
+

Add Sites for Backup

+
+
+ +
+
+ + +
+
+
+
+ + + + + + + + + + + + + + + + + + +
+ Last Run + + All Sites + + Frequency ({$ currently $}) + + Retention ({$ currently $}) + + Current Status +
+ {$ lastRun $} + + {$ allSites $} + + + + {$ currentStatus $} +
+
+
+
+
+ {% trans "View Logs" %} + + +
+
+ +
+
+
+ + + + + + + + + + + + + +
+ Sites + + Action +
+ + +
+
+
+ +
+
+
+{% endblock %} diff --git a/backup/templates/backup/googleDriveV2.html b/backup/templates/backup/googleDriveV2.html new file mode 100644 index 000000000..0798f2390 --- /dev/null +++ b/backup/templates/backup/googleDriveV2.html @@ -0,0 +1,287 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + +
+
+
+

Set up Google Drive Backups -

+ {% trans "Remote Backups" %} +
+
+

On this page you can set up and manage Google Drive + Backups.

+
+
+
+
+

On this page you can set up and manage Google + Drive Backups. +

+
+ {% trans "Setup new Account" %} + + +
+
+
+
+
+
+
+

Select Drive Account

+
+
+ +
+
+ +
+
+
+
+

Select Backup Frequency

+
+
+ +
+
+ Currently: {$ currently $} +
+
+
+
+

Add Sites for Backup

+
+
+ +
+
+ +
+
+
+
+

Backup File Retention + (Paid Feature )

+
+
+ +
+
+
+
+
+ {% trans "View Logs" %} + + +
+
+ +
+
+
+ + + + + + + + + + + + + +
+ Sites + + Action +
+ + +
+
+
+ +
+
+
+{% endblock %} diff --git a/backup/templates/backup/remoteBackupsV2.html b/backup/templates/backup/remoteBackupsV2.html new file mode 100644 index 000000000..ac9a5a50d --- /dev/null +++ b/backup/templates/backup/remoteBackupsV2.html @@ -0,0 +1,146 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + +
+
+
+

Remote Backups -

+ {% trans "Remote Transfer" %} +
+
+

This feature can import website(s) from remote server +

+
+

Remote Backups

+ +
+
+

+
+
+

IP Address

+
+
+ +
+
+
+
+

Password

+
+
+ +
+
+
+ +
+
+
+ +
+
+ +
+
+
+ +
+
+

{$ error_message $}

+
+
+

{% trans "Could not connect, please refresh this page." %}

+
+
+

{% trans "Accounts Successfully Fetched from remote server." %}

+
+
+

{% trans "Backup Process successfully started." %}

+
+
+

{% trans "Backup successfully cancelled." %}

+
+
+
+
+
+

+
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + +
+ Website + + PHP + + Package + + Email + + +
+ + + + + +
+
+
+
+ +
+
+ +
+
+
+{% endblock %} diff --git a/backup/urls.py b/backup/urls.py index abe492927..66c4e66dd 100755 --- a/backup/urls.py +++ b/backup/urls.py @@ -9,6 +9,7 @@ urlpatterns = [ url(r'^restoreSite', views.restoreSite, name='restoreSite'), url(r'^V2/restoreSiteV2', views.restoreSiteV2, name='restoreSiteV2'), url(r'^gDrive$', views.gDrive, name='gDrive'), + url(r'^V2/gDriveV2$', views.gDriveV2, name='gDriveV2'), url(r'^gDriveSetup$', views.gDriveSetup, name='gDriveSetup'), url(r'^fetchgDriveSites$', views.fetchgDriveSites, name='fetchgDriveSites'), url(r'^addSitegDrive$', views.addSitegDrive, name='addSitegDrive'), @@ -28,6 +29,7 @@ urlpatterns = [ url(r'^submitRestore', views.submitRestore, name='submitRestore'), url(r'^backupDestinations', views.backupDestinations, name='backupDestinations'), + url(r'^V2/backupDestinationsV2', views.backupDestinationsV2, name='backupDestinationsV2'), url(r'^getCurrentBackupDestinations', views.getCurrentBackupDestinations, name='getCurrentBackupDestinations'), @@ -38,6 +40,7 @@ urlpatterns = [ url(r'^deleteDestination', views.deleteDestination, name='deleteDestination'), url(r'^scheduleBackup', views.scheduleBackup, name='scheduleBackup'), + url(r'^V2/scheduleBackupV2', views.scheduleBackupV2, name='scheduleBackupV2'), url(r'^getCurrentBackupSchedules', views.getCurrentBackupSchedules, name='getCurrentBackupSchedules'), @@ -46,6 +49,7 @@ urlpatterns = [ url(r'^scheduleDelete', views.scheduleDelete, name='scheduleDelete'), url(r'^remoteBackups', views.remoteBackups, name='remoteBackups'), + url(r'^V2/remoteBackupsV2', views.remoteBackupsV2, name='remoteBackupsV2'), url(r'^submitRemoteBackups', views.submitRemoteBackups, name='submitRemoteBackups'), url(r'^getRemoteTransferStatus', views.getRemoteTransferStatus, name='getRemoteTransferStatus'), url(r'^remoteBackupRestore', views.remoteBackupRestore, name='remoteBackupRestore'), diff --git a/backup/views.py b/backup/views.py index 59ec6d5df..5c512e541 100755 --- a/backup/views.py +++ b/backup/views.py @@ -51,6 +51,15 @@ def gDrive(request): return redirect(loadLoginPage) +def gDriveV2(request): + try: + userID = request.session['userID'] + bm = BackupManager() + return bm.gDriveV2(request, userID) + except KeyError: + return redirect(loadLoginPage) + + def gDriveSetup(request): try: userID = request.session['userID'] @@ -238,6 +247,15 @@ def backupDestinations(request): return redirect(loadLoginPage) +def backupDestinationsV2(request): + try: + userID = request.session['userID'] + bm = BackupManager() + return bm.backupDestinationsV2(request, userID) + except KeyError: + return redirect(loadLoginPage) + + def submitDestinationCreation(request): try: userID = request.session['userID'] @@ -304,6 +322,15 @@ def scheduleBackup(request): return redirect(loadLoginPage) +def scheduleBackupV2(request): + try: + userID = request.session['userID'] + bm = BackupManager() + return bm.scheduleBackupV2(request, userID) + except KeyError: + return redirect(loadLoginPage) + + def getCurrentBackupSchedules(request): try: userID = request.session['userID'] @@ -360,6 +387,15 @@ def remoteBackups(request): return redirect(loadLoginPage) +def remoteBackupsV2(request): + try: + userID = request.session['userID'] + bm = BackupManager() + return bm.remoteBackupsV2(request, userID) + except KeyError: + return redirect(loadLoginPage) + + def submitRemoteBackups(request): try: userID = request.session['userID'] diff --git a/baseTemplate/templates/baseTemplate/dashboardV2.html b/baseTemplate/templates/baseTemplate/dashboardV2.html index eeecf00ac..05f018774 100644 --- a/baseTemplate/templates/baseTemplate/dashboardV2.html +++ b/baseTemplate/templates/baseTemplate/dashboardV2.html @@ -607,35 +607,28 @@ {# #} {# #} -