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() diff --git a/cli/cyberPanel.py b/cli/cyberPanel.py index 1ac06edd8..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("%I-%M-%S-%a-%b-%Y") + # 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])