(self)
return status.returncode == 0
Prune the backup
Prune the backup
Prune the backup
def pruneBackup(self):
        """Prune the backup"""

        # Buil repository path specification
        pathSpec = self.repositoryPath

        # Use the passphrase saved
        os.environ["BORG_PASSPHRASE"] = self.key

        # Run the borg command
        args = [ 'borg', 'prune' ]

        # Buil repository path specification
        args.append('--prefix')
        args.append(self.archivePrefix)

        args.append('-v')
        args.append('--list')
        args.append('--stats')

        args.append('--show-rc')

        # Append periodicity
        args.append('--keep-daily')
        args.append(self.keepDaily)
        args.append('--keep-weekly')
        args.append(self.keepWeekly)
        args.append('--keep-monthly')
        args.append(self.keepMonthly)

        # Finally, specify the path
        args.append(pathSpec)

        # Run the process, and keep stdout / stderr
        status = self.runCommand(args, "Pruning repository")

        if status.returncode == 0:
            self.lastBackupInfo['prune'] = "Prune status:\n"
        else:
            self.lastBackupInfo['prune'] = "Prune errors:\n"

        # Save details for reporting
        if status.stdout != None:
            self.lastBackupInfo['prune'] += status.stdout
        if status.stderr != None:
            self.lastBackupInfo['prune'] += status.stderr

        # If not, raise an exception to avoid writing files in a directory
        # that is not a repository
        if status.returncode != 0:
            logging.error("Error when pruning backup: " + status.stderr)
            raise RuntimeError(status.stderr)

        return status.returncode == 0
def pruneBackup ( self ) : # Buil repository path specification pathSpec = self . repositoryPath # Use the passphrase saved os . environ [ "BORG_PASSPHRASE" ] = self . key # Run the borg command args = [ 'borg' , 'prune' ] # Buil repository path specification args . append ( '--prefix' ) args . append ( self . archivePrefix ) args . append ( '-v' ) args . append ( '--list' ) args . append ( '--stats' ) args . append ( '--show-rc' ) # Append periodicity args . append ( '--keep-daily' ) args . append ( self . keepDaily ) args . append ( '--keep-weekly' ) args . append ( self . keepWeekly ) args . append ( '--keep-monthly' ) args . append ( self . keepMonthly ) # Finally, specify the path args . append ( pathSpec ) # Run the process, and keep stdout / stderr status = self . runCommand ( args , "Pruning repository" ) if status . returncode == 0 : self . lastBackupInfo [ 'prune' ] = "Prune status:\n" else : self . lastBackupInfo [ 'prune' ] = "Prune errors:\n" # Save details for reporting if status . stdout != None : self . lastBackupInfo [ 'prune' ] += status . stdout if status . stderr != None : self . lastBackupInfo [ 'prune' ] += status . stderr # If not, raise an exception to avoid writing files in a directory # that is not a repository if status . returncode != 0 : logging . error ( "Error when pruning backup: " + status . stderr ) raise RuntimeError ( status . stderr ) return status . returncode == 0