<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def restore(self, chksum, choose_first=False):
 """ Restore mets.xml to previous state """

        log = getLogger('ocrd.workspace_backup.restore')
        bak = None
        candidates = glob(join(self.backup_directory, '%s*' % chksum))
        if not candidates:
            log.error("No backup found: %s" % chksum)
            return
        if len(candidates) > 1 and not choose_first:
            raise Exception("Not unique, could be\n%s" % '\n'.join(candidates))
        bak = candidates[0]
        self.add()
        log.info("Restoring from %s/mets.xml" % bak)
        src = join(bak, 'mets.xml')
        dest = self.workspace.mets_target
        log.debug('cp "%s" "%s"', src, dest)
        copy(src, dest)
        self.workspace.reload_mets()