From fd71a275d5c482c2e9d5d371daa77e58beb975f2 Mon Sep 17 00:00:00 2001 From: WhatTheServer Date: Thu, 24 Dec 2020 18:42:52 -0500 Subject: [PATCH 1/3] Update cyberPanel.py Fix old datetime format to match current so its uniform and clear. --- cli/cyberPanel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/cyberPanel.py b/cli/cyberPanel.py index 1ac06edd8..ffe62b031 100755 --- a/cli/cyberPanel.py +++ b/cli/cyberPanel.py @@ -335,7 +335,7 @@ class cyberPanel: def createBackup(self, virtualHostName): try: - backupLogPath = "/usr/local/lscp/logs/backup_log."+time.strftime("%I-%M-%S-%a-%b-%Y") + backupLogPath = "/usr/local/lscp/logs/backup_log."+time.strftime("%m.%d.%Y_%H-%M-%S") print('Backup logs to be generated in %s' % (backupLogPath)) From 74f818769bc23c937f6218e08be470c9c8bf4a74 Mon Sep 17 00:00:00 2001 From: WhatTheServer Date: Thu, 24 Dec 2020 19:52:21 -0500 Subject: [PATCH 2/3] Update cyberPanel.py Setup cyberpanel cli createBackup to where it can accept an optional argument for the backup path so scripting full backups to other paths can be done easily. --- cli/cyberPanel.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/cli/cyberPanel.py b/cli/cyberPanel.py index ffe62b031..939f0b7e5 100755 --- a/cli/cyberPanel.py +++ b/cli/cyberPanel.py @@ -333,13 +333,22 @@ class cyberPanel: ## Backup Functions - def createBackup(self, virtualHostName): + def createBackup(self, virtualHostName, backupPath=None): try: - backupLogPath = "/usr/local/lscp/logs/backup_log."+time.strftime("%m.%d.%Y_%H-%M-%S") + # Setup default backup path to /home//backup if not passed in + if backupPath is None: + backupPath = '/home/' + virtualHostName + '/backup' + + # remove trailing slash in path + backupPath = backupPath.rstrip("/") + backuptime = time.strftime("%m.%d.%Y_%H-%M-%S") + backupLogPath = "/usr/local/lscp/logs/backup_log." + backuptime print('Backup logs to be generated in %s' % (backupLogPath)) - - backupSchedule.createLocalBackup(virtualHostName, backupLogPath) + tempStoragePath = backupPath + '/backup-' + virtualHostName + '-' + backuptime + backupName = 'backup-' + virtualHostName + '-' + backuptime + backupDomain = virtualHostName + backupUtilities.submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain) except BaseException as msg: logger.writeforCLI(str(msg), "Error", stack()[0][3]) From ae728b0c588c0d5011c8f023140ffa368e9bdb77 Mon Sep 17 00:00:00 2001 From: WhatTheServer Date: Thu, 24 Dec 2020 19:56:04 -0500 Subject: [PATCH 3/3] Update cliParser.py Add argument to pass an optional backupPath to cyberpanel cli createBackup function so you can call the createBackup function and specify to backup to a specific path like another mount or path for scripting backups where you want them vs being hardcoded to /home//backup --- cli/cliParser.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cli/cliParser.py b/cli/cliParser.py index 20dae31b6..00c7cb7d7 100755 --- a/cli/cliParser.py +++ b/cli/cliParser.py @@ -22,6 +22,7 @@ class cliParser: parser.add_argument('--dkim', help='DKIM Signing') parser.add_argument('--openBasedir', help='To enable or disable open_basedir protection for domain.') parser.add_argument('--fileName', help='Complete path to a file that needs to be restored.') + parser.add_argument('--backupPath', help='Backup path to use when generating a backup.') ## Package Arguments. @@ -69,4 +70,4 @@ class cliParser: parser.add_argument('--siteTitle', help='Site Title for application installers.') parser.add_argument('--path', help='Path for application installers.') - return parser.parse_args() \ No newline at end of file + return parser.parse_args()