mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-07-01 00:08:47 +02:00
function to create rclone backend
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user