(self)
return status.returncode == 0
Create the backup itself
Create the backup itself
Create the backup itself
def createBackup(self):
        """Create the backup itself"""

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

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

        # Build repository path specification
        pathSpec = self.repositoryPath + '::' + self.archivePrefix + '{now}'

        args.append('--filter')
        args.append('AME')

        args.append('--verbose')

        # Check if we compress the content
        if self.compression != None:
            args.append('--compression')
            args.append(self.compression)

        # Exclude some files and directories
        args.append('--exclude-caches')
        args.append('--exclude-from')
        args.append('/etc/homebox/backup-exclude')

        # Add rate limiting if specified
        if self.rateLimit != None:
            args.append('--remote-ratelimit')
            args.append(self.rateLimit)

        # Reporting
        args.append('--stats')
        args.append('--show-rc')

        args.append(pathSpec)

        # Which paths to backup
        args.append('/home')
        args.append('/var/backups')

        # Start he process
        status = self.runCommand(args, "Creating repository")

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

        # Save details for reporting
        if status.stdout != None:
            self.lastBackupInfo['create'] += status.stdout
        if status.stderr != None:
            self.lastBackupInfo['create'] += 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 creating backup: " + status.stderr)
            raise RuntimeError(status.stderr)

        return status.returncode == 0
def createBackup ( self ) : # Use the passphrase saved os . environ [ "BORG_PASSPHRASE" ] = self . key # Run the borg command args = [ 'borg' , 'create' ] # Build repository path specification pathSpec = self . repositoryPath + '::' + self . archivePrefix + '{now}' args . append ( '--filter' ) args . append ( 'AME' ) args . append ( '--verbose' ) # Check if we compress the content if self . compression != None : args . append ( '--compression' ) args . append ( self . compression ) # Exclude some files and directories args . append ( '--exclude-caches' ) args . append ( '--exclude-from' ) args . append ( '/etc/homebox/backup-exclude' ) # Add rate limiting if specified if self . rateLimit != None : args . append ( '--remote-ratelimit' ) args . append ( self . rateLimit ) # Reporting args . append ( '--stats' ) args . append ( '--show-rc' ) args . append ( pathSpec ) # Which paths to backup args . append ( '/home' ) args . append ( '/var/backups' ) # Start he process status = self . runCommand ( args , "Creating repository" ) if status . returncode == 0 : self . lastBackupInfo [ 'create' ] = "Creation status:\n" else : self . lastBackupInfo [ 'create' ] = "Creation errors:\n" # Save details for reporting if status . stdout != None : self . lastBackupInfo [ 'create' ] += status . stdout if status . stderr != None : self . lastBackupInfo [ 'create' ] += 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 creating backup: " + status . stderr ) raise RuntimeError ( status . stderr ) return status . returncode == 0