function to create rclone backend

This commit is contained in:
usman@cyberpersons.com
2023-02-27 13:15:01 +05:00
parent b06886a875
commit 131168dc9e
2 changed files with 34 additions and 0 deletions

View File

@@ -25,12 +25,44 @@ class CPBackupsV2:
COMPLETED = 2
FAILED = 3
### RCLONE BACKEND TYPES
SFTP = 1
LOCAL = 2
RUSTIC_PATH = '/usr/bin/rustic'
RCLONE_CONFIG = '/root/.config/rclone/rclone.conf'
command = 'rclone obscure hosting'
def __init__(self, data):
self.data = data
pass
def SetupRcloneBackend(self, type, config):
self.LocalRclonePath = f'/home/{self.website.domain}/.config/rclone'
self.ConfigFilePath = f'{self.LocalRclonePath}/rclone.conf'
command = f'mkdir -p {self.LocalRclonePath}'
ProcessUtilities.executioner(command, self.website.externalApp)
if type == CPBackupsV2.SFTP:
## 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)
@staticmethod
def FetchCurrentTimeStamp():
import time

View File

@@ -454,7 +454,9 @@ def refreshLicense(request):
cpbuv2 = CPBackupsV2(
{'domain': 'cyberpanel.net', 'BasePath': '/home/backup', 'BackupDatabase': 1, 'BackupData': 1,
'BackupEmails': 1})
RcloneData = {"name":'testremote', "host":"", "user": "", "port": "22", "path": "custombackups", "password":"",}
cpbuv2.InitiateBackup()
cpbuv2.SetupRcloneBackend(CPBackupsV2.SFTP, RcloneData)
#cpbuv2.InstallRustic()
final_dic = {'status': 1}