diff --git a/api/views.py b/api/views.py index 86f51bc2c..4f64c00cf 100644 --- a/api/views.py +++ b/api/views.py @@ -360,11 +360,12 @@ def remoteTransfer(request): username = data['username'] password = data['password'] ipAddress = data['ipAddress'] + accountsToTransfer = data['accountsToTransfer'] admin = Administrator.objects.get(userName=username) if hashPassword.check_password(admin.password, password): dir = str(randint(1000, 9999)) - transferRequest = rBackup.remoteBackup.remoteTransfer(ipAddress, dir) + transferRequest = rBackup.remoteBackup.remoteTransfer(ipAddress, dir,accountsToTransfer) if transferRequest[0] == 1: pass diff --git a/backup/static/backup/backup.js b/backup/static/backup/backup.js index 4f2fe8272..ae8c7cef4 100644 --- a/backup/static/backup/backup.js +++ b/backup/static/backup/backup.js @@ -1228,6 +1228,7 @@ app.controller('remoteBackupControl', function($scope, $http, $timeout) { var data = { ipAddress: IPAddress, password: password, + accountsToTransfer:websitesToBeBacked, }; var config = { diff --git a/backup/views.py b/backup/views.py index a64290d96..83e209be9 100644 --- a/backup/views.py +++ b/backup/views.py @@ -1096,18 +1096,6 @@ def submitRemoteBackups(request): return HttpResponse(data_ret) - #transferRequest = rBackup.remoteBackup.postRemoteTransfer(ipAddress, ownIP, password, sshkey) - - #if transferRequest[0] == 1: - # pass - #else: - # final_json = json.dumps({'status': 0, 'error_message': transferRequest[1]}) - # return HttpResponse(final_json) - - #data_ret = {'status': 1, 'error_message': "None", "dir":transferRequest[1]} - #json_data = json.dumps(data_ret) - #return HttpResponse(json_data) - else: return HttpResponse("This URL only accepts POST requests") @@ -1124,10 +1112,12 @@ def starRemoteTransfer(request): ipAddress = data['ipAddress'] password = data['password'] + accountsToTransfer = data['accountsToTransfer'] + ownIP = requests.get('https://api.ipify.org').text - finalData = json.dumps({'username': "admin", "password": password,"ipAddress": ownIP}) + finalData = json.dumps({'username': "admin", "password": password,"ipAddress": ownIP,"accountsToTransfer":accountsToTransfer}) url = "https://" + ipAddress + ":8090/api/remoteTransfer" @@ -1171,15 +1161,6 @@ def getRemoteTransferStatus(request): if data['fetchStatus'] == 1: if data['status'].find("Backups are successfully generated and received on") > -1: - #try: - #finalData = json.dumps({"backupDir": dir}) - #r = requests.post("http://localhost:5003/backup/remoteBackupRestore", data=finalData) - #logging.CyberCPLogFileWriter.writeToFile(r.text) - #except BaseException,msg: - # logging.CyberCPLogFileWriter.writeToFile("Something happened here:" +str(msg)) - - - data = {'remoteTransferStatus': 1, 'error_message': "None", "status": data['status'],'backupsSent': 1} json_data = json.dumps(data) return HttpResponse(json_data) diff --git a/plogical/remoteBackup.py b/plogical/remoteBackup.py index 0302728f9..d10c603ab 100644 --- a/plogical/remoteBackup.py +++ b/plogical/remoteBackup.py @@ -211,8 +211,6 @@ class remoteBackup: r = requests.post("http://localhost:5003/backup/submitRestore", data=finalData) data = json.loads(r.text) - logging.CyberCPLogFileWriter.writeToFile(r.text) - if data['restoreStatus'] == 1: while (1): @@ -411,12 +409,12 @@ class remoteBackup: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [startBackup]") @staticmethod - def backupProcess(ipAddress, dir, backupLogPath,folderNumber): + def backupProcess(ipAddress, dir, backupLogPath,folderNumber,accountsToTransfer): try: ## dir is without forward slash - for virtualHost in os.listdir("/home"): + for virtualHost in accountsToTransfer: try: @@ -497,7 +495,7 @@ class remoteBackup: logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [backupProcess]") @staticmethod - def remoteTransfer(ipAddress, dir): + def remoteTransfer(ipAddress, dir,accountsToTransfer): try: destination = "/home/backup/transfer-" + dir backupLogPath = destination + "/backup_log" @@ -535,7 +533,7 @@ class remoteBackup: return [0, "Host is down"] - p = Process(target=remoteBackup.backupProcess, args=(ipAddress, destination, backupLogPath,dir,)) + p = Process(target=remoteBackup.backupProcess, args=(ipAddress, destination, backupLogPath,dir,accountsToTransfer)) p.start() pid = open(destination + '/pid', "w")