Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
Pruning and checking after successful backup.
"""
profile = BackupProfileModel.get(id=profile_id)
logger.info('Doing post-backup jobs for %s', profile.name)
if profile.prune_on:
msg = BorgPruneThread.prepare(profile)
if msg['ok']:
prune_thread = BorgPruneThread(msg['cmd'], msg)
prune_thread.start()
prune_thread.wait()
# Refresh archives
msg = BorgListRepoThread.prepare(profile)
if msg['ok']:
list_thread = BorgListRepoThread(msg['cmd'], msg)
list_thread.start()
list_thread.wait()
validation_cutoff = date.today() - timedelta(days=7 * profile.validation_weeks)
recent_validations = EventLogModel.select().where(
(
EventLogModel.subcommand == 'check'
) & (
EventLogModel.start_time > validation_cutoff
) & (
EventLogModel.repo_url == profile.repo.url
)
).count()
if profile.validation_on and recent_validations == 0:
msg = BorgCheckThread.prepare(profile)
if msg['ok']:
def list_action(self):
params = BorgListRepoThread.prepare(self.profile())
if params['ok']:
thread = BorgListRepoThread(params['cmd'], params, parent=self)
thread.updated.connect(self._set_status)
thread.result.connect(self.list_result)
self._toggle_all_buttons(False)
thread.start()