Exemplo n.º 1
0
 def list_action(self):
     params = BorgListRepoThread.prepare(self.profile())
     if params['ok']:
         thread = BorgListRepoThread(params['cmd'], params, parent=self.app)
         thread.updated.connect(self._set_status)
         thread.result.connect(self.list_result)
         self._toggle_all_buttons(False)
         thread.start()
Exemplo n.º 2
0
    def post_backup_tasks(self, profile_id):
        """
        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 snapshots
                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']:
                check_thread = BorgCheckThread(msg['cmd'], msg)
                check_thread.start()
                check_thread.wait()

        logger.info('Finished background task for profile %s', profile.name)