From 2a48d3a257c60da6d359d4942de3a41cfd128aad Mon Sep 17 00:00:00 2001 From: "usman@cyberpersons.com" Date: Tue, 28 Feb 2023 18:18:42 +0500 Subject: [PATCH] config backup --- plogical/Backupsv2.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/plogical/Backupsv2.py b/plogical/Backupsv2.py index 8e1b1ba15..df93daa78 100644 --- a/plogical/Backupsv2.py +++ b/plogical/Backupsv2.py @@ -90,7 +90,9 @@ pass = {ObsecurePassword} self.buv2.website.BackupLock = 0 self.buv2.website.save() - def BackupConfig(self): + + ## parent is used to link this snapshot with master snapshot + def BackupConfig(self, parent): ### Backup config file to rustic command = f'chown {self.website.externalApp}:{self.website.externalApp} {self.FinalPathRuctic}' @@ -102,7 +104,7 @@ pass = {ObsecurePassword} #command = f'chown cyberpanel:cyberpanel {self.FinalPathRuctic}' #ProcessUtilities.executioner(command) - command = f'rustic -r {self.repo} backup {self.FinalPathRuctic}/config.json --password ""' + command = f'rustic -r {self.repo} backup {self.FinalPathRuctic}/config.json --password "" --parent {parent}' ProcessUtilities.executioner(command) def InitiateBackup(self): @@ -413,6 +415,10 @@ pass = {ObsecurePassword} files_new = result['summary']['files_new'] ## basically new files in backup total_duration = result['summary']['total_duration'] ## time taken + ### Config is saved with each database, snapshot of config is attached to db snapshot with parent + + self.BackupConfig(SnapShotID) + except BaseException as msg: self.UpdateStatus(f'Backup failed as no snapshot id found, error: {str(msg)}', CPBackupsV2.FAILED) @@ -485,6 +491,10 @@ pass = {ObsecurePassword} files_new = result['summary']['files_new'] ## basically new files in backup total_duration = result['summary']['total_duration'] ## time taken + ### Config is saved with each backup, snapshot of config is attached to data snapshot with parent + + self.BackupConfig(SnapShotID) + except BaseException as msg: self.UpdateStatus(f'Backup failed as no snapshot id found, error: {str(msg)}', CPBackupsV2.FAILED) return 0 @@ -521,6 +531,10 @@ pass = {ObsecurePassword} files_new = result['summary']['files_new'] ## basically new files in backup total_duration = result['summary']['total_duration'] ## time taken + ### Config is saved with each email backup, snapshot of config is attached to email snapshot with parent + + self.BackupConfig(SnapShotID) + except BaseException as msg: self.UpdateStatus(f'Backup failed as no snapshot id found, error: {str(msg)}', CPBackupsV2.FAILED) return 0