From 1754e485561a7bf074489817424240a30e29452e Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 20 Feb 2023 14:59:34 +0500 Subject: [PATCH 1/2] rustic installed --- backup/tests.py | 14 +++++++++----- plogical/Backupsv2.py | 38 +++++++++++++++++++++++++++++++++++++- serverStatus/views.py | 1 + 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/backup/tests.py b/backup/tests.py index ede01f165..181d7a768 100755 --- a/backup/tests.py +++ b/backup/tests.py @@ -1,7 +1,11 @@ -import time +import requests -# ts stores the time in seconds -ts = time.time() +url = "https://api.github.com/repos/rustic-rs/rustic/releases/latest" # Replace with your API endpoint URL +response = requests.get(url) -# print the current timestamp -print(ts) \ No newline at end of file +if response.status_code == 200: + data = response.json() + print(data['tag_name']) + # Do something with the data +else: + print("Request failed with status code:", response.status_code) \ No newline at end of file diff --git a/plogical/Backupsv2.py b/plogical/Backupsv2.py index 775c31d66..850a54fe0 100644 --- a/plogical/Backupsv2.py +++ b/plogical/Backupsv2.py @@ -3,9 +3,14 @@ import json import os import sys import time +import requests sys.path.append('/usr/local/CyberCP') import django +import plogical.CyberCPLogFileWriter as logging + + + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") try: @@ -320,6 +325,36 @@ class CPBackupsV2: return 1 + def Incrmentalback(self): + try: + + logging.CyberCPLogFileWriter.writeToFile('--------------habbi-----------test----------') + url = "https://api.github.com/repos/rustic-rs/rustic/releases/latest" + response = requests.get(url) + + if response.status_code == 200: + data = response.json() + version = data['tag_name'] + name = data['name'] + + #wget -P /home/rustic https://github.com/rustic-rs/rustic/releases/download/v0.4.3/rustic-v0.4.3-x86_64-unknown-linux-gnu.tar.gz + + + #tar xzf /home/rustic/rustic-v0.4.3-x86_64-unknown-linux-gnu.tar.gz -C /home/rustic/ + + #sudo mv filename /usr/bin/ + command = 'wget -P /home/rustic https://github.com/rustic-rs/rustic/releases/download/%s/rustic-%s-x86_64-unknown-linux-gnu.tar.gz' %(version, version) + ProcessUtilities.executioner(command) + + command = 'tar xzf /home/rustic/rustic-%s-x86_64-unknown-linux-gnu.tar.gz -C /home/rustic//'%(version) + ProcessUtilities.executioner(command) + + command = 'sudo mv /home/rustic/rustic /usr/bin/' + ProcessUtilities.executioner(command) + + except BaseException as msg: + print('Error: %s'%msg) + if __name__ == "__main__": try: parser = argparse.ArgumentParser(description='CyberPanel Backup Generator') @@ -334,4 +369,5 @@ if __name__ == "__main__": except: cpbuv2 = CPBackupsV2({'domain': 'cyberpanel.net', 'BasePath': '/home/backup', 'BackupDatabase': 1, 'BackupData': 1, 'BackupEmails': 1} ) - cpbuv2.InitiateBackup() \ No newline at end of file + cpbuv2.InitiateBackup() + cpbuv2.Incrmentalback() \ No newline at end of file diff --git a/serverStatus/views.py b/serverStatus/views.py index 85ef9bad9..726a05788 100755 --- a/serverStatus/views.py +++ b/serverStatus/views.py @@ -455,6 +455,7 @@ def refreshLicense(request): {'domain': 'cyberpanel.net', 'BasePath': '/home/backup', 'BackupDatabase': 1, 'BackupData': 1, 'BackupEmails': 1}) cpbuv2.InitiateBackup() + cpbuv2.Incrmentalback() final_dic = {'status': 1} final_json = json.dumps(final_dic) From 8f7bc85fe6de1d35e2f53bde2a54c9e8a63329f9 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 20 Feb 2023 15:25:37 +0500 Subject: [PATCH 2/2] rustic installed1 --- plogical/Backupsv2.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plogical/Backupsv2.py b/plogical/Backupsv2.py index 850a54fe0..9f3f89a3e 100644 --- a/plogical/Backupsv2.py +++ b/plogical/Backupsv2.py @@ -328,7 +328,6 @@ class CPBackupsV2: def Incrmentalback(self): try: - logging.CyberCPLogFileWriter.writeToFile('--------------habbi-----------test----------') url = "https://api.github.com/repos/rustic-rs/rustic/releases/latest" response = requests.get(url) @@ -352,6 +351,8 @@ class CPBackupsV2: command = 'sudo mv /home/rustic/rustic /usr/bin/' ProcessUtilities.executioner(command) + command = 'rm -rf /home/rustic' + ProcessUtilities.executioner(command) except BaseException as msg: print('Error: %s'%msg)