mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-01-05 23:29:45 +01:00
Bug Fixes to Remote Transfer
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -1228,6 +1228,7 @@ app.controller('remoteBackupControl', function($scope, $http, $timeout) {
|
||||
var data = {
|
||||
ipAddress: IPAddress,
|
||||
password: password,
|
||||
accountsToTransfer:websitesToBeBacked,
|
||||
};
|
||||
|
||||
var config = {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user