(self, version, location="/")
return status.returncode == 0
Restore the content of the backup to a specific location
Restore the content of the backup to a specific location
Restore the content of the backup to a specific location
def restoreBackup(self, version, location="/"):
        """Restore the content of the backup to a specific location"""

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

        # Change to the target directory
        os.chdir(location)

        # Standard extractions
        args = [ 'borg', 'extract', '--info' ]

        # Finally add the repository path
        args.append(self.repositoryPath + "::" + version)

        # Star the process and keep stdout / stderr
        status = self.runCommand(args, "Restoring backup")

        # Save details for reporting
        if status.returncode == 0:
            self.lastBackupInfo['restore'] = "Restoration status: Success"
        else:
            self.lastBackupInfo['restore'] = "Restoration errors: Error"

        if status.stdout != None:
            self.lastBackupInfo['restore'] += status.stdout
        if status.stderr != None:
            self.lastBackupInfo['restore'] += 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 checking backup: " + status.stderr)
            raise RuntimeError(status.stderr)

        return status.returncode == 0
def restoreBackup ( self , version , location = "/" ) : # Use the passphrase saved os . environ [ "BORG_PASSPHRASE" ] = self . key # Change to the target directory os . chdir ( location ) # Standard extractions args = [ 'borg' , 'extract' , '--info' ] # Finally add the repository path args . append ( self . repositoryPath + "::" + version ) # Star the process and keep stdout / stderr status = self . runCommand ( args , "Restoring backup" ) # Save details for reporting if status . returncode == 0 : self . lastBackupInfo [ 'restore' ] = "Restoration status: Success" else : self . lastBackupInfo [ 'restore' ] = "Restoration errors: Error" if status . stdout != None : self . lastBackupInfo [ 'restore' ] += status . stdout if status . stderr != None : self . lastBackupInfo [ 'restore' ] += 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 checking backup: " + status . stderr ) raise RuntimeError ( status . stderr ) return status . returncode == 0