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 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + {% for items in websiteList %} + + {% endfor %} + + + + +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ + + +
+ +
+ + + + + + + + + + + + + + + + + + + + +
{% trans "Snapshot ID" %}{% trans "Date" %}{% trans "Host" %}{% trans "Path" %}{% trans "Actions" %}
+ Restore +
+
+
+ + + + + + + + + + + + + + + +{% 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" %} +