-
diff --git a/IncBackups/templates/IncBackups/createBackup.html b/IncBackups/templates/IncBackups/createBackup.html
index 87b03f487..d4cdbaa59 100755
--- a/IncBackups/templates/IncBackups/createBackup.html
+++ b/IncBackups/templates/IncBackups/createBackup.html
@@ -10,7 +10,7 @@
-
@@ -174,8 +174,6 @@
Restore Points
Restore
- Restore and Reconstruct
|
diff --git a/IncBackups/templates/IncBackups/incrementalDestinations.html b/IncBackups/templates/IncBackups/incrementalDestinations.html
index 602cad196..9b6af3205 100755
--- a/IncBackups/templates/IncBackups/incrementalDestinations.html
+++ b/IncBackups/templates/IncBackups/incrementalDestinations.html
@@ -12,7 +12,7 @@
{% trans "Set up Incremental Back up Destinations" %} - {% trans "Remote Backups" %}
diff --git a/IncBackups/views.py b/IncBackups/views.py
index 3b1d406a6..1bc582a6e 100644
--- a/IncBackups/views.py
+++ b/IncBackups/views.py
@@ -3,7 +3,7 @@
from django.shortcuts import render
from plogical.acl import ACLManager
-from django.shortcuts import HttpResponse
+from django.shortcuts import HttpResponse, redirect
from plogical.processUtilities import ProcessUtilities
from plogical.virtualHostUtilities import virtualHostUtilities
import json
@@ -15,6 +15,7 @@
from random import randint
import time
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
+from loginSystem.views import loadLoginPage
# Create your views here.
@@ -36,17 +37,19 @@ def createBackup(request):
path = '/home/cyberpanel/sftp'
- for items in os.listdir(path):
- destinations.append('sftp:%s' % (items))
+ if os.path.exists(path):
+ for items in os.listdir(path):
+ destinations.append('sftp:%s' % (items))
path = '/home/cyberpanel/aws'
-
- for items in os.listdir(path):
- destinations.append('s3:s3.amazonaws.com/%s' % (items))
+ if os.path.exists(path):
+ for items in os.listdir(path):
+ destinations.append('s3:s3.amazonaws.com/%s' % (items))
return defRenderer(request, 'IncBackups/createBackup.html', {'websiteList': websitesName, 'destinations': destinations})
except BaseException, msg:
- return HttpResponse(str(msg))
+ logging.writeToFile(str(msg))
+ return redirect(loadLoginPage)
def backupDestinations(request):
try:
@@ -58,7 +61,8 @@ def backupDestinations(request):
return defRenderer(request, 'IncBackups/incrementalDestinations.html', {})
except BaseException, msg:
- return HttpResponse(str(msg))
+ logging.writeToFile(str(msg))
+ return redirect(loadLoginPage)
def addDestination(request):
try:
@@ -559,15 +563,19 @@ def scheduleBackups(request):
path = '/home/cyberpanel/sftp'
- for items in os.listdir(path):
- destinations.append('sftp:%s' % (items))
+ if os.path.exists(path):
+ for items in os.listdir(path):
+ destinations.append('sftp:%s' % (items))
- for items in os.listdir(path):
- destinations.append('s3:s3.amazonaws.com/%s' % (items))
+ path = '/home/cyberpanel/aws'
+ if os.path.exists(path):
+ for items in os.listdir(path):
+ destinations.append('s3:s3.amazonaws.com/%s' % (items))
return defRenderer(request, 'IncBackups/backupSchedule.html', {'websiteList': websitesName, 'destinations': destinations})
except BaseException, msg:
- return HttpResponse(str(msg))
+ logging.writeToFile(str(msg))
+ return redirect(loadLoginPage)
def submitBackupSchedule(request):
try:
diff --git a/baseTemplate/templates/baseTemplate/index.html b/baseTemplate/templates/baseTemplate/index.html
index cdb5d524d..55250f022 100755
--- a/baseTemplate/templates/baseTemplate/index.html
+++ b/baseTemplate/templates/baseTemplate/index.html
@@ -588,7 +588,7 @@
-
+
{% trans "Incremental Back up" %}
@@ -596,10 +596,10 @@
- {% trans "Create Back up" %}
+ title="{% trans 'Create Back up' %}">{% trans "Create/Restore Back up" %}
- {% trans "Add Destinations" %}
+ title="{% trans 'Restore Back up' %}">{% trans "Add/Remove Destinations" %}
- {% trans "Schedule Back ups" %}
diff --git a/install/install.py b/install/install.py
index 7637ea805..da748a247 100755
--- a/install/install.py
+++ b/install/install.py
@@ -951,7 +951,7 @@ def download_install_CyberPanel(self, mysqlPassword, mysql):
os.chdir(self.path)
- command = "wget http://cyberpanel.sh/CyberPanel.1.9.0.tar.gz"
+ command = "wget http://cyberpanel.sh/CyberPanel.1.9.1.tar.gz"
# command = "wget http://cyberpanel.sh/CyberPanelTemp.tar.gz"
preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]',
'CyberPanel Download',
@@ -960,7 +960,7 @@ def download_install_CyberPanel(self, mysqlPassword, mysql):
##
count = 0
- command = "tar zxf CyberPanel.1.9.0.tar.gz"
+ command = "tar zxf CyberPanel.1.9.1.tar.gz"
# command = "tar zxf CyberPanelTemp.tar.gz"
preFlightsChecks.call(command, self.distro, '[download_install_CyberPanel]',
'Extract CyberPanel', 1, 1, os.EX_OSERR)
@@ -1051,7 +1051,7 @@ def download_install_CyberPanel(self, mysqlPassword, mysql):
path = "/usr/local/CyberCP/version.txt"
writeToFile = open(path, 'w')
writeToFile.writelines('1.9\n')
- writeToFile.writelines('0')
+ writeToFile.writelines('1')
writeToFile.close()
except:
pass
@@ -3689,6 +3689,51 @@ def setUpFirstAccount():
except:
pass
+ def installRestic(self):
+ try:
+
+ CentOSPath = '/etc/redhat-release'
+
+ if os.path.exists(CentOSPath):
+ command = 'yum-config-manager --add-repo https://copr.fedorainfracloud.org/coprs/copart/restic/repo/epel-7/copart-restic-epel-7.repo'
+ preFlightsChecks.call(command, self.distro, '[installRestic]',
+ 'Add restic repo.',
+ 1, 0, os.EX_OSERR)
+
+ command = 'yum install restic -y'
+ preFlightsChecks.call(command, self.distro, '[installRestic]',
+ 'Install Restic.',
+ 1, 0, os.EX_OSERR)
+ else:
+ command = 'apt-get update -y'
+ preFlightsChecks.call(command, self.distro, '[installRestic]',
+ 'Install Restic.',
+ 1, 0, os.EX_OSERR)
+
+ command = 'apt-get install restic -y'
+ preFlightsChecks.call(command, self.distro, '[installRestic]',
+ 'Install Restic.',
+ 1, 0, os.EX_OSERR)
+
+
+ cronTab = '/etc/crontab'
+
+ data = open(cronTab, 'r').read()
+
+ if data.find('IncScheduler') == -1:
+ cronJob = '0 12 * * * root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/IncBackups/IncScheduler.py Daily'
+
+ writeToFile = open(cronTab, 'a')
+ writeToFile.writelines(cronJob)
+
+ cronJob = '0 0 * * 0 root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/IncBackups/IncScheduler.py Daily'
+ writeToFile.writelines(cronJob)
+ writeToFile.close()
+
+
+ except:
+ pass
+
def main():
parser = argparse.ArgumentParser(description='CyberPanel Installer')
@@ -3813,6 +3858,7 @@ def main():
checks.download_install_phpmyadmin()
checks.setupCLI()
checks.setup_cron()
+ checks.installRestic()
# checks.installdnsPython()
## Install and Configure OpenDKIM.
diff --git a/loginSystem/views.py b/loginSystem/views.py
index 4ae220be5..8774ecb4d 100755
--- a/loginSystem/views.py
+++ b/loginSystem/views.py
@@ -218,7 +218,7 @@ def loadLoginPage(request):
firstName="Cyber",lastName="Panel", acl=acl, token=token)
admin.save()
- vers = version(currentVersion="1.9", build=0)
+ vers = version(currentVersion="1.9", build=1)
vers.save()
package = Package(admin=admin, packageName="Default", diskSpace=1000,
diff --git a/plogical/adminPass.py b/plogical/adminPass.py
index 1d969c7f2..1734cedf9 100755
--- a/plogical/adminPass.py
+++ b/plogical/adminPass.py
@@ -31,7 +31,7 @@ def main():
firstName="Cyber", lastName="Panel", acl=acl, token=token)
admin.save()
- vers = version(currentVersion="1.9", build=0)
+ vers = version(currentVersion="1.9", build=1)
vers.save()
package = Package(admin=admin, packageName="Default", diskSpace=1000,
diff --git a/plogical/upgrade.py b/plogical/upgrade.py
index df44d02f8..dd03b1142 100755
--- a/plogical/upgrade.py
+++ b/plogical/upgrade.py
@@ -1175,6 +1175,73 @@ def GeneralMigrations():
except:
pass
+ @staticmethod
+ def IncBackupMigrations():
+ try:
+ connection, cursor = Upgrade.setupConnection('cyberpanel')
+
+ query = """CREATE TABLE `IncBackups_backupjob` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `destination` varchar(300) NOT NULL,
+ `frequency` varchar(50) NOT NULL,
+ `websiteData` int(11) NOT NULL,
+ `websiteDatabases` int(11) NOT NULL,
+ `websiteDataEmails` int(11) NOT NULL,
+ PRIMARY KEY (`id`)
+)"""
+ try:
+ cursor.execute(query)
+ except:
+ pass
+
+ query = """CREATE TABLE `IncBackups_incjob` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `date` datetime(6) NOT NULL,
+ `website_id` int(11) NOT NULL,
+ PRIMARY KEY (`id`),
+ KEY `IncBackups_incjob_website_id_aad31bf6_fk_websiteFu` (`website_id`),
+ CONSTRAINT `IncBackups_incjob_website_id_aad31bf6_fk_websiteFu` FOREIGN KEY (`website_id`) REFERENCES `websiteFunctions_websites` (`id`)
+)"""
+ try:
+ cursor.execute(query)
+ except:
+ pass
+
+ query = """CREATE TABLE `IncBackups_jobsites` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `website` varchar(300) NOT NULL,
+ `job_id` int(11) NOT NULL,
+ PRIMARY KEY (`id`),
+ KEY `IncBackups_jobsites_job_id_494a1f69_fk_IncBackups_backupjob_id` (`job_id`),
+ CONSTRAINT `IncBackups_jobsites_job_id_494a1f69_fk_IncBackups_backupjob_id` FOREIGN KEY (`job_id`) REFERENCES `IncBackups_backupjob` (`id`)
+)"""
+ try:
+ cursor.execute(query)
+ except:
+ pass
+
+ query = """CREATE TABLE `IncBackups_jobsnapshots` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `type` varchar(300) NOT NULL,
+ `snapshotid` varchar(50) NOT NULL,
+ `job_id` int(11) NOT NULL,
+ `destination` varchar(200) NOT NULL,
+ PRIMARY KEY (`id`),
+ KEY `IncBackups_jobsnapshots_job_id_a8237ca8_fk_IncBackups_incjob_id` (`job_id`),
+ CONSTRAINT `IncBackups_jobsnapshots_job_id_a8237ca8_fk_IncBackups_incjob_id` FOREIGN KEY (`job_id`) REFERENCES `IncBackups_incjob` (`id`)
+)"""
+ try:
+ cursor.execute(query)
+ except:
+ pass
+
+ try:
+ connection.close()
+ except:
+ pass
+ except:
+ pass
+
@staticmethod
def enableServices():
try:
@@ -1267,6 +1334,11 @@ def downloadAndUpgrade(versionNumbring):
if items.find('CLManager') > -1:
CLManager = 0
+ IncBackups = 1
+ for items in data:
+ if items.find('IncBackups') > -1:
+ IncBackups = 0
+
Upgrade.stdOut('Restoring settings file!')
writeToFile = open("/usr/local/CyberCP/CyberCP/settings.py", 'w')
@@ -1295,9 +1367,13 @@ def downloadAndUpgrade(versionNumbring):
if manageServices == 1:
writeToFile.writelines(" 'manageServices',\n")
+
if CLManager == 1:
writeToFile.writelines(" 'CLManager',\n")
+ if IncBackups == 1:
+ writeToFile.writelines(" 'IncBackups',\n")
+
else:
writeToFile.writelines(items)
@@ -1542,7 +1618,6 @@ def installPHP73():
Upgrade.executioner(command, 'Set default PHP 7.0, 0')
-
@staticmethod
def someDirectories():
command = "mkdir -p /usr/local/lscpd/admin/"
@@ -1741,6 +1816,37 @@ def upgradeDovecot():
except BaseException, msg:
Upgrade.stdOut(str(msg) + " [upgradeDovecot]")
+ @staticmethod
+ def installRestic():
+ CentOSPath = '/etc/redhat-release'
+
+ if os.path.exists(CentOSPath):
+ command = 'yum-config-manager --add-repo https://copr.fedorainfracloud.org/coprs/copart/restic/repo/epel-7/copart-restic-epel-7.repo'
+ Upgrade.executioner(command, 'Add restic repo.')
+
+ command = 'yum install restic -y'
+ Upgrade.executioner(command, 'Install Restic')
+ else:
+ command = 'apt-get update -y'
+ Upgrade.executioner(command, 'Install Restic')
+
+ command = 'apt-get install restic -y'
+ Upgrade.executioner(command, 'Install Restic')
+
+ cronTab = '/etc/crontab'
+
+ data = open(cronTab, 'r').read()
+
+ if data.find('IncScheduler') == -1:
+ cronJob = '0 12 * * * root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/IncBackups/IncScheduler.py Daily'
+
+ writeToFile = open(cronTab, 'a')
+ writeToFile.writelines(cronJob)
+
+ cronJob = '0 0 * * 0 root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/IncBackups/IncScheduler.py Daily'
+ writeToFile.writelines(cronJob)
+ writeToFile.close()
+
@staticmethod
def upgrade():
@@ -1796,6 +1902,8 @@ def upgrade():
Upgrade.emailMarketingMigrationsa()
Upgrade.dockerMigrations()
Upgrade.CLMigrations()
+ Upgrade.IncBackupMigrations()
+ Upgrade.installRestic()
##
diff --git a/serverLogs/views.py b/serverLogs/views.py
index 7bffba1a0..300509a09 100755
--- a/serverLogs/views.py
+++ b/serverLogs/views.py
@@ -12,6 +12,7 @@
from plogical.virtualHostUtilities import virtualHostUtilities
from plogical.acl import ACLManager
from plogical.processUtilities import ProcessUtilities
+import os
# Create your views here.
@@ -130,9 +131,15 @@ def getLogsFromFile(request):
elif type == "error":
fileName = installUtilities.Server_root_path + "/logs/error.log"
elif type == "email":
- fileName = "/var/log/maillog"
+ if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
+ fileName = "/var/log/maillog"
+ else:
+ fileName = "/var/log/mail.log"
elif type == "ftp":
- fileName = "/var/log/messages"
+ if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
+ fileName = "/var/log/messages"
+ else:
+ fileName = "/var/log/syslog"
elif type == "modSec":
fileName = "/usr/local/lsws/logs/auditmodsec.log"
elif type == "cyberpanel":
@@ -195,4 +202,4 @@ def clearLogFile(request):
logging.CyberCPLogFileWriter.writeToFile(str(msg))
data_ret = {'cleanStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
- return HttpResponse(json_data)
\ No newline at end of file
+ return HttpResponse(json_data)
diff --git a/static/IncBackups/IncBackups.js b/static/IncBackups/IncBackups.js
new file mode 100644
index 000000000..af2436303
--- /dev/null
+++ b/static/IncBackups/IncBackups.js
@@ -0,0 +1,745 @@
+//*** Backup site ****//
+
+app.controller('createIncrementalBackups', 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 = JSON.parse(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.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 = 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.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) {
+ }
+
+ };
+
+
+});
+
+///** Backup site ends **///
+
+
+app.controller('incrementalDestinations', 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 = 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 = "/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'
+ });
+ }
+
+ };
+
+
+});
+
+
+app.controller('scheduleBackupInc', 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,
+ 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: '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'
+ });
+ }
+
+ };
+
+ $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) {
+ $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);
+ }
+ } 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'
+ });
+ }
+
+ };
+
+
+});
\ No newline at end of file