diff --git a/IncBackups/static/IncBackups/IncBackups.js b/IncBackups/static/IncBackups/IncBackups.js
index 79b13571e..a1f0305ff 100644
--- a/IncBackups/static/IncBackups/IncBackups.js
+++ b/IncBackups/static/IncBackups/IncBackups.js
@@ -1141,4 +1141,25 @@ app.controller('restoreRemoteBackupsInc', function ($scope, $http, $timeout) {
};
+});
+
+
+app.controller('createV2Backups', 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');
+ }
+ }
+
+
+ $scope.setupAccount = function(){
+ window.open("https://platform.cyberpersons.com/gDrive?name=" + $scope.accountName + '&server=' + window.location.href + 'Setup');
+ };
});
\ No newline at end of file
diff --git a/IncBackups/templates/IncBackups/createV2Backup.html b/IncBackups/templates/IncBackups/createV2Backup.html
index 6b5eb8ddd..6f0e3e28c 100644
--- a/IncBackups/templates/IncBackups/createV2Backup.html
+++ b/IncBackups/templates/IncBackups/createV2Backup.html
@@ -1,6 +1,6 @@
{% extends "baseTemplate/index.html" %}
{% load i18n %}
-{% block title %}{% trans "Create Incremental Backup" %}{% endblock %}
+{% block title %}{% trans "Create V2 Backup" %}{% endblock %}
{% block content %}
{% load static %}
@@ -9,219 +9,74 @@
-
-
-
{% trans "This page can be used to create incremental backups for your websites." %}
+
+
+
+
+ {% trans "Backup V2" %}
+
+
+
-
habbi test v2 backup
-
-{#
#}
-{#
#}
-{#
#}
-{# {% trans "Backup Website" %}
#}
-{#
#}
-{#
#}
-{##}
-{##}
-{#
#}
-{##}
-{##}
-{#
#}
-{#
#}
-{#
#}
-
diff --git a/IncBackups/urls.py b/IncBackups/urls.py
index fa6882672..cec048a9b 100644
--- a/IncBackups/urls.py
+++ b/IncBackups/urls.py
@@ -24,5 +24,6 @@ urlpatterns = [
url(r'^addWebsite$', views.add_website, name='addWebsite'),
### V2 Backups URls
url(r'^createV2Backup$', views.createV2Backup, name='createV2Backup'),
+ url(r'^createV2BackupSetup$', views.createV2BackupSetup, name='createV2BackupSetup'),
]
\ No newline at end of file
diff --git a/IncBackups/views.py b/IncBackups/views.py
index a4c92b9ab..2a44e1843 100644
--- a/IncBackups/views.py
+++ b/IncBackups/views.py
@@ -6,8 +6,11 @@ from pathlib import Path
from random import randint
from django.shortcuts import HttpResponse, redirect
+
+from backup.backupManager import BackupManager
from loginSystem.models import Administrator
from loginSystem.views import loadLoginPage
+from plogical.Backupsv2 import CPBackupsV2
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
from plogical.acl import ACLManager
from plogical.httpProc import httpProc
@@ -709,17 +712,47 @@ def add_website(request):
def createV2Backup(request):
try:
- #user_id, current_acl = _get_user_acl(request)
- # if ACLManager.currentContextPermission(current_acl, 'createBackup') == 0:
- # return ACLManager.loadError()
+ 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)
- proc = httpProc(request, 'IncBackups/createV2Backup.html', 'createBackup')
+ proc = httpProc(request, 'IncBackups/createV2Backup.html')
return proc.render()
- # return def_renderer(request, 'IncBackups/createV2Backup.html', 'createBackup')
+
except BaseException as msg:
- final_json = json.dumps({'status': 0, 'error_message': str(msg)})
+ logging.writeToFile(str(msg))
+ return redirect(loadLoginPage)
+
+
+def createV2BackupSetup(request):
+ try:
+ userID = request.session['userID']
+
+ req_data={}
+ req_data['token'] = request.GET.get('t')
+ req_data['refresh_token'] = request.GET.get('r')
+ req_data['token_uri'] = request.GET.get('to')
+ req_data['scopes'] = request.GET.get('s')
+ req_data['accountname'] = request.GET.get('n')
+
+ cpbuv2 = CPBackupsV2(
+ {'domain': 'cyberpanel.net', 'BasePath': '/home/backup', 'BackupDatabase': 1, 'BackupData': 1,
+ 'BackupEmails': 1, 'BackendName': 'testremote'})
+
+ # RcloneData = {"name": 'testremote', "host": "staging.cyberpanel.net", "user": "abcds2751", "port": "22",
+ # "password": "hosting", }
+ cpbuv2.SetupRcloneBackend(CPBackupsV2.GDrive, req_data)
+ cpbuv2.InitiateBackup()
+
+ # wm = BackupManager()
+ # return wm.gDriveSetup(userID, request)
+
+ final_dic = {'status': 1}
+ final_json = json.dumps(final_dic)
return HttpResponse(final_json)
+ except KeyError:
+ return redirect(loadLoginPage)
\ No newline at end of file
diff --git a/plogical/Backupsv2.py b/plogical/Backupsv2.py
index 06f51ce5d..eef067ec6 100644
--- a/plogical/Backupsv2.py
+++ b/plogical/Backupsv2.py
@@ -28,6 +28,7 @@ class CPBackupsV2:
### RCLONE BACKEND TYPES
SFTP = 1
LOCAL = 2
+ GDrive = 3
RUSTIC_PATH = '/usr/bin/rustic'
RCLONE_CONFIG = '/root/.config/rclone/rclone.conf'
@@ -66,6 +67,22 @@ pass = {ObsecurePassword}
command = f"echo '{content}' > {self.ConfigFilePath}"
ProcessUtilities.executioner(command, self.website.externalApp, True)
+ command = f"chmod 600 {self.ConfigFilePath}"
+ ProcessUtilities.executioner(command, self.website.externalApp)
+ elif type == CPBackupsV2.GDrive:
+ ## config = {"name":, "host":, "user":, "port":, "path":, "password":,}
+ command = f'rclone obscure {config["password"]}'
+ ObsecurePassword = ProcessUtilities.outputExecutioner(command).rstrip('\n')
+
+ content = f'''[{config["name"]}]
+type = sftp
+host = {config["host"]}
+user = {config["user"]}
+pass = {ObsecurePassword}
+'''
+ command = f"echo '{content}' > {self.ConfigFilePath}"
+ ProcessUtilities.executioner(command, self.website.externalApp, True)
+
command = f"chmod 600 {self.ConfigFilePath}"
ProcessUtilities.executioner(command, self.website.externalApp)