diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 2bf26a3d5..e3ba0cb48 100755
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -28,56 +28,96 @@
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
+
+
+
@@ -94,11 +134,6 @@
- setupVirtualEnv
- python
- setupDKIM
- submitWebsiteCreation
- submitWebsitecrea
createDomain
submitDomain
getpass
@@ -121,9 +156,14 @@
emailForwarding
emailFor
selectForwardingEmail
- getEmailsForDomain
submitForwardDeletion
+ getEmailsForDomain
forwardEmail
+ export
+ restoreRemoteBackupsInc
+ backupData
+ backupData(
+ sftpFunction
admin.api == 1
@@ -154,7 +194,6 @@
@@ -229,7 +269,33 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -239,22 +305,22 @@
-
+
-
-
-
-
+
+
+
+
@@ -443,18 +509,18 @@
-
+
-
+
-
+
@@ -538,27 +604,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -591,16 +636,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -741,13 +776,6 @@
-
-
-
-
-
-
-
@@ -755,26 +783,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -785,13 +793,6 @@
-
-
-
-
-
-
-
@@ -809,42 +810,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1197,25 +1162,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1237,5 +1183,131 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/IncBackups/IncBackupsControl.py b/IncBackups/IncBackupsControl.py
index 1ac99f815..63d68c783 100644
--- a/IncBackups/IncBackupsControl.py
+++ b/IncBackups/IncBackupsControl.py
@@ -2,10 +2,12 @@
import os
import os.path
import sys
+
sys.path.append('/usr/local/CyberCP')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
import django
+
try:
django.setup()
except:
@@ -25,12 +27,16 @@
from plogical.dnsUtilities import DNS
from mailServer.models import Domains as eDomains
from random import randint
+import json
+from django.shortcuts import HttpResponse
+
try:
from plogical.virtualHostUtilities import virtualHostUtilities
from plogical.mailUtilities import mailUtilities
except:
pass
+
class IncJobs(multi.Thread):
def __init__(self, function, extraArgs):
@@ -51,6 +57,72 @@ def run(self):
self.createBackup()
elif self.function == 'restorePoint':
self.restorePoint()
+ elif self.function == 'remoteRestore':
+ self.restorePoint()
+
+ def getRemoteBackups(self):
+ if self.jobid.destination == 'local':
+ path = '/home/%s/incbackup' % (self.website)
+ command = 'export RESTIC_PASSWORD=%s && restic -r %s snapshots' % (self.passwordFile, path)
+ return ProcessUtilities.outputExecutioner(command).split('\n')
+ elif self.jobid.destination[:4] == 'sftp':
+ path = '/home/backup/%s' % (self.website)
+ command = 'export RESTIC_PASSWORD=%s PATH=${PATH}:/usr/bin && restic -r %s:%s snapshots' % (
+ self.passwordFile, self.backupDestinations, path)
+ return ProcessUtilities.outputExecutioner(command).split('\n')
+ else:
+ path = '/home/%s/incbackup' % (self.website)
+ command = 'export RESTIC_PASSWORD=%s && restic -r %s snapshots' % (self.passwordFile, path)
+ return ProcessUtilities.outputExecutioner(command).split('\n')
+
+ def fetchCurrentBackups(self):
+ try:
+ self.website = self.extraArgs['website']
+ self.backupDestinations = self.extraArgs['backupDestinations']
+ self.passwordFile = self.extraArgs['password']
+
+ remotePath = '/home/backup/%s' % (self.website)
+
+ command = 'export RESTIC_PASSWORD=%s PATH=${PATH}:/usr/bin && restic -r %s:%s snapshots' % (
+ self.passwordFile, self.backupDestinations, remotePath)
+ result = ProcessUtilities.outputExecutioner(command).split('\n')
+
+ activator = 0
+ json_data = "["
+ checker = 0
+
+ for items in result:
+ if items.find('---------------') > -1:
+ if activator == 0:
+ activator = 1
+ continue
+ else:
+ activator = 0
+
+ if activator:
+ entry = items.split(' ')
+ logging.writeToFile(str(entry))
+
+ dic = {'id': entry[0],
+ 'date': "%s %s" % (entry[2], entry[3]),
+ 'host': entry[5],
+ 'path': entry[-1]
+ }
+
+ if checker == 0:
+ json_data = json_data + json.dumps(dic)
+ checker = 1
+ else:
+ json_data = json_data + ',' + json.dumps(dic)
+
+ json_data = json_data + ']'
+ final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data})
+ return HttpResponse(final_json)
+
+ except BaseException, msg:
+ logging.writeToFile(str(msg))
+
+ ####
def getAWSData(self):
key = self.backupDestinations.split('/')[-1]
@@ -58,22 +130,24 @@ def getAWSData(self):
secret = open(path, 'r').read()
return key, secret
- def awsFunction(self, fType, backupPath = None, snapshotID = None, bType = None):
+ def awsFunction(self, fType, backupPath=None, snapshotID=None, bType=None):
try:
if fType == 'backup':
key, secret = self.getAWSData()
command = 'export AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s && restic -r s3:s3.amazonaws.com/%s backup %s --password-file %s' % (
- key, secret, self.website.domain, backupPath, self.passwordFile)
+ key, secret, self.website.domain, backupPath, self.passwordFile)
result = ProcessUtilities.outputExecutioner(command)
logging.statusWriter(self.statusPath, result, 1)
snapShotid = result.split(' ')[-2]
if bType == 'database':
- newSnapshot = JobSnapshots(job=self.jobid, type='%s:%s' % (bType, backupPath.split('/')[-1].strip('.sql')),
+ newSnapshot = JobSnapshots(job=self.jobid,
+ type='%s:%s' % (bType, backupPath.split('/')[-1].strip('.sql')),
snapshotid=snapShotid,
destination=self.backupDestinations)
else:
- newSnapshot = JobSnapshots(job=self.jobid, type='%s:%s' % (bType, backupPath), snapshotid=snapShotid,
- destination=self.backupDestinations)
+ newSnapshot = JobSnapshots(job=self.jobid, type='%s:%s' % (bType, backupPath),
+ snapshotid=snapShotid,
+ destination=self.backupDestinations)
newSnapshot.save()
else:
self.backupDestinations = self.jobid.destination
@@ -88,9 +162,9 @@ def awsFunction(self, fType, backupPath = None, snapshotID = None, bType = None)
logging.statusWriter(self.statusPath, "%s [88][5009]" % (str(msg)), 1)
return 0
- def localFunction(self, backupPath, type, restore = None):
+ def localFunction(self, backupPath, type, restore=None):
if restore == None:
- command = 'restic -r %s backup %s --password-file %s' % (self.repoPath, backupPath, self.passwordFile)
+ command = 'restic -r %s backup %s --password-file %s --exclude %s' % (self.repoPath, backupPath, self.passwordFile, self.repoPath)
result = ProcessUtilities.outputExecutioner(command)
logging.statusWriter(self.statusPath, result, 1)
snapShotid = result.split(' ')[-2]
@@ -107,11 +181,11 @@ def localFunction(self, backupPath, type, restore = None):
else:
repoLocation = '/home/%s/incbackup' % (self.website)
command = 'restic -r %s restore %s --target / --password-file %s' % (
- repoLocation, self.jobid.snapshotid, self.passwordFile)
+ repoLocation, self.jobid.snapshotid, self.passwordFile)
result = ProcessUtilities.outputExecutioner(command)
logging.statusWriter(self.statusPath, result, 1)
- def sftpFunction(self, backupPath, type, restore = None):
+ def sftpFunction(self, backupPath, type, restore=None):
if restore == None:
remotePath = '/home/backup/%s' % (self.website.domain)
command = 'export PATH=${PATH}:/usr/bin && restic -r %s:%s backup %s --password-file %s --exclude %s' % (
@@ -132,7 +206,7 @@ def sftpFunction(self, backupPath, type, restore = None):
else:
repoLocation = '/home/backup/%s' % (self.website)
command = 'export PATH=${PATH}:/usr/bin && restic -r %s:%s restore %s --target / --password-file %s' % (
- self.jobid.destination, repoLocation, self.jobid.snapshotid, self.passwordFile)
+ self.jobid.destination, repoLocation, self.jobid.snapshotid, self.passwordFile)
result = ProcessUtilities.outputExecutioner(command)
logging.statusWriter(self.statusPath, result, 1)
@@ -160,7 +234,8 @@ def restoreDatabase(self):
else:
self.awsFunction('restore', '', self.jobid.snapshotid)
- if mysqlUtilities.mysqlUtilities.restoreDatabaseBackup(self.jobid.type.split(':')[1].rstrip('.sql'), '/home/cyberpanel', 'dummy', 'dummy') == 0:
+ if mysqlUtilities.mysqlUtilities.restoreDatabaseBackup(self.jobid.type.split(':')[1].rstrip('.sql'),
+ '/home/cyberpanel', 'dummy', 'dummy') == 0:
raise BaseException
try:
@@ -189,7 +264,6 @@ def restoreEmail(self):
def reconstructWithMeta(self):
try:
-
if self.jobid.destination == 'local':
self.localFunction('none', 'none', 1)
elif self.jobid.destination[:4] == 'sftp':
@@ -219,7 +293,6 @@ def restorePoint(self):
logging.statusWriter(self.statusPath, message, 1)
self.passwordFile = '/home/%s/%s' % (self.website, self.website)
-
##
if self.jobid.type[:8] == 'database':
@@ -433,10 +506,11 @@ def backupData(self):
else:
self.awsFunction('backup', backupPath, '', 'data')
- logging.statusWriter(self.statusPath, 'Data for %s backed to %s.' % (self.website.domain, self.backupDestinations), 1)
+ logging.statusWriter(self.statusPath,
+ 'Data for %s backed to %s.' % (self.website.domain, self.backupDestinations), 1)
return 1
except BaseException, msg:
- logging.statusWriter(self.statusPath,'%s. [IncJobs.backupData.223][5009]' % str(msg), 1)
+ logging.statusWriter(self.statusPath, '%s. [IncJobs.backupData.223][5009]' % str(msg), 1)
return 0
def backupDatabases(self):
@@ -461,10 +535,11 @@ def backupDatabases(self):
try:
os.remove('/home/cyberpanel/%s.sql' % (items.dbName))
except BaseException, msg:
- logging.statusWriter(self.statusPath,'Failed to delete database: %s. [IncJobs.backupDatabases.456]' % str(msg), 1)
+ logging.statusWriter(self.statusPath,
+ 'Failed to delete database: %s. [IncJobs.backupDatabases.456]' % str(msg), 1)
return 1
except BaseException, msg:
- logging.statusWriter(self.statusPath,'%s. [IncJobs.backupDatabases.269][5009]' % str(msg), 1)
+ logging.statusWriter(self.statusPath, '%s. [IncJobs.backupDatabases.269][5009]' % str(msg), 1)
return 0
def emailBackup(self):
@@ -480,11 +555,11 @@ def emailBackup(self):
else:
self.awsFunction('backup', backupPath, '', 'email')
-
- logging.statusWriter(self.statusPath, 'Emails for %s backed to %s.' % (self.website.domain, self.backupDestinations), 1)
+ logging.statusWriter(self.statusPath,
+ 'Emails for %s backed to %s.' % (self.website.domain, self.backupDestinations), 1)
return 1
except BaseException, msg:
- logging.statusWriter(self.statusPath,'%s. [IncJobs.emailBackup.269][5009]' % str(msg), 1)
+ logging.statusWriter(self.statusPath, '%s. [IncJobs.emailBackup.269][5009]' % str(msg), 1)
return 0
def metaBackup(self):
@@ -500,11 +575,11 @@ def metaBackup(self):
else:
self.awsFunction('backup', backupPath, '', 'meta')
-
- logging.statusWriter(self.statusPath, 'Meta for %s backed to %s.' % (self.website.domain, self.backupDestinations), 1)
+ logging.statusWriter(self.statusPath,
+ 'Meta for %s backed to %s.' % (self.website.domain, self.backupDestinations), 1)
return 1
except BaseException, msg:
- logging.statusWriter(self.statusPath,'%s. [IncJobs.metaBackup.269][5009]' % str(msg), 1)
+ logging.statusWriter(self.statusPath, '%s. [IncJobs.metaBackup.269][5009]' % str(msg), 1)
return 0
def initiateRepo(self):
@@ -518,20 +593,23 @@ def initiateRepo(self):
elif self.backupDestinations[:4] == 'sftp':
remotePath = '/home/backup/%s' % (self.website.domain)
- command = 'export PATH=${PATH}:/usr/bin && restic init --repo %s:%s --password-file %s' % (self.backupDestinations, remotePath, self.passwordFile)
+ command = 'export PATH=${PATH}:/usr/bin && restic init --repo %s:%s --password-file %s' % (
+ self.backupDestinations, remotePath, self.passwordFile)
result = ProcessUtilities.outputExecutioner(command)
logging.statusWriter(self.statusPath, result, 1)
else:
- key,secret = self.getAWSData()
- command = 'export AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s && restic -r s3:s3.amazonaws.com/%s init --password-file %s' % (key, secret, self.website.domain, self.passwordFile)
+ key, secret = self.getAWSData()
+ command = 'export AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s && restic -r s3:s3.amazonaws.com/%s init --password-file %s' % (
+ key, secret, self.website.domain, self.passwordFile)
result = ProcessUtilities.outputExecutioner(command)
logging.statusWriter(self.statusPath, result, 1)
return 1
- logging.statusWriter(self.statusPath, 'Repo %s initiated for %s.' % (self.backupDestinations, self.website.domain), 1)
+ logging.statusWriter(self.statusPath,
+ 'Repo %s initiated for %s.' % (self.backupDestinations, self.website.domain), 1)
return 1
except BaseException, msg:
- logging.statusWriter(self.statusPath,'%s. [IncJobs.initiateRepo.47][5009]' % str(msg), 1)
+ logging.statusWriter(self.statusPath, '%s. [IncJobs.initiateRepo.47][5009]' % str(msg), 1)
return 0
def createBackup(self):
@@ -562,7 +640,6 @@ def createBackup(self):
command = 'chmod 600 %s' % (self.passwordFile)
ProcessUtilities.executioner(command)
-
if self.initiateRepo() == 0:
return
@@ -589,6 +666,7 @@ def createBackup(self):
command = 'rm -f %s' % (metaPathNew)
ProcessUtilities.executioner(command)
except BaseException, msg:
- logging.statusWriter(self.statusPath,'Failed to delete meta file: %s. [IncJobs.createBackup.591]' % str(msg), 1)
+ logging.statusWriter(self.statusPath,
+ 'Failed to delete meta file: %s. [IncJobs.createBackup.591]' % str(msg), 1)
- logging.statusWriter(self.statusPath, 'Completed', 1)
\ No newline at end of file
+ logging.statusWriter(self.statusPath, 'Completed', 1)
diff --git a/IncBackups/static/IncBackups/IncBackups.js b/IncBackups/static/IncBackups/IncBackups.js
index af2436303..8bc93dbb0 100644
--- a/IncBackups/static/IncBackups/IncBackups.js
+++ b/IncBackups/static/IncBackups/IncBackups.js
@@ -742,4 +742,221 @@ app.controller('scheduleBackupInc', function ($scope, $http) {
};
+});
+
+
+app.controller('restoreRemoteBackupsInc', 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 () {
+ getBackupStatus();
+ $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;
+ $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 = JSON.parse(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.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) {
+ }
+
+ };
+
+
});
\ No newline at end of file
diff --git a/IncBackups/templates/IncBackups/restoreRemoteBackups.html b/IncBackups/templates/IncBackups/restoreRemoteBackups.html
new file mode 100755
index 000000000..69dd71d69
--- /dev/null
+++ b/IncBackups/templates/IncBackups/restoreRemoteBackups.html
@@ -0,0 +1,123 @@
+{% extends "baseTemplate/index.html" %}
+{% load i18n %}
+{% block title %}{% trans "Restore Remote Incremental Backups" %}{% endblock %}
+{% block content %}
+
+ {% load static %}
+
+ {% get_current_language as LANGUAGE_CODE %}
+
+
+
+
+
{% trans "Restore Remote Incremental Backups" %} - {% trans "Backup Docs" %}
+
+
{% trans "This page can be used to restore remote incremental backups for your websites." %}
+
+
+
+
+
+ {% trans "Back up Website" %}
+
+
+
+
+
+
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/IncBackups/urls.py b/IncBackups/urls.py
index 2976cedb0..fcf10fce5 100644
--- a/IncBackups/urls.py
+++ b/IncBackups/urls.py
@@ -3,6 +3,7 @@
urlpatterns = [
url(r'^createBackup$', views.createBackup, name='createBackupInc'),
+ url(r'^restoreRemoteBackups$', views.restoreRemoteBackups, name='restoreRemoteBackupsInc'),
url(r'^backupDestinations$', views.backupDestinations, name='backupDestinationsInc'),
url(r'^addDestination$', views.addDestination, name='addDestinationInc'),
url(r'^populateCurrentRecords$', views.populateCurrentRecords, name='populateCurrentRecordsInc'),
diff --git a/IncBackups/views.py b/IncBackups/views.py
index 2425be9bd..8276e02ad 100644
--- a/IncBackups/views.py
+++ b/IncBackups/views.py
@@ -288,36 +288,55 @@ def fetchCurrentBackups(request):
else:
return ACLManager.loadErrorJson()
- website = Websites.objects.get(domain=backupDomain)
+ try:
+ backupDestinations = data['backupDestinations']
- backups = website.incjob_set.all()
+ extraArgs = {}
+ extraArgs['website'] = backupDomain
+ extraArgs['backupDestinations'] = backupDestinations
+ try:
+ extraArgs['password'] = data['password']
+ except:
+ final_json = json.dumps({'status': 0, 'error_message': "Please supply the password."})
+ return HttpResponse(final_json)
- json_data = "["
- checker = 0
+ startJob = IncJobs('Dummpy', extraArgs)
+ return startJob.fetchCurrentBackups()
- for items in reversed(backups):
+ except:
- includes = ""
+ website = Websites.objects.get(domain=backupDomain)
- jobs = items.jobsnapshots_set.all()
+ backups = website.incjob_set.all()
- for job in jobs:
- includes = '%s,%s:%s' % (includes, job.type, job.snapshotid)
+ json_data = "["
+ checker = 0
- dic = {'id': items.id,
- 'date': str(items.date),
- 'includes': includes
- }
+ for items in reversed(backups):
+
+ includes = ""
+
+ jobs = items.jobsnapshots_set.all()
+
+ for job in jobs:
+ includes = '%s,%s:%s' % (includes, job.type, job.snapshotid)
+
+ dic = {'id': items.id,
+ 'date': str(items.date),
+ 'includes': includes
+ }
+
+ if checker == 0:
+ json_data = json_data + json.dumps(dic)
+ checker = 1
+ else:
+ json_data = json_data + ',' + json.dumps(dic)
+
+ json_data = json_data + ']'
+ final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data})
+ return HttpResponse(final_json)
- if checker == 0:
- json_data = json_data + json.dumps(dic)
- checker = 1
- else:
- json_data = json_data + ',' + json.dumps(dic)
- json_data = json_data + ']'
- final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data})
- return HttpResponse(final_json)
except BaseException, msg:
final_dic = {'status': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
@@ -686,4 +705,33 @@ def scheduleDelete(request):
except BaseException, msg:
final_json = json.dumps({'status': 0, 'error_message': str(msg)})
- return HttpResponse(final_json)
\ No newline at end of file
+ return HttpResponse(final_json)
+
+def restoreRemoteBackups(request):
+ try:
+ userID = request.session['userID']
+ currentACL = ACLManager.loadedACL(userID)
+
+ if ACLManager.currentContextPermission(currentACL, 'createBackup') == 0:
+ return ACLManager.loadError()
+
+ websitesName = ACLManager.findAllSites(currentACL, userID)
+
+ destinations = []
+ destinations.append('local')
+
+ path = '/home/cyberpanel/sftp'
+
+ if os.path.exists(path):
+ for items in os.listdir(path):
+ destinations.append('sftp:%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/restoreRemoteBackups.html', {'websiteList': websitesName, 'destinations': destinations})
+ except BaseException, msg:
+ logging.writeToFile(str(msg))
+ return redirect(loadLoginPage)
\ No newline at end of file
diff --git a/baseTemplate/templates/baseTemplate/index.html b/baseTemplate/templates/baseTemplate/index.html
index 55250f022..548bae63d 100755
--- a/baseTemplate/templates/baseTemplate/index.html
+++ b/baseTemplate/templates/baseTemplate/index.html
@@ -604,6 +604,9 @@
{% trans "Schedule Back ups" %}
+ {% trans "Restore from Remote" %}
+