

def _add_to_checkpoint_dir(self, cp_dir, save_files, save_notes):
    'Add save files to checkpoint directory.\n\n        :param str cp_dir: Checkpoint directory filepath\n        :param set save_files: set of files to save\n        :param str save_notes: notes about changes made during the save\n\n        :raises IOError: if unable to open cp_dir + FILEPATHS file\n        :raises .ReverterError: if unable to add checkpoint\n\n        '
    le_util.make_or_verify_dir(cp_dir, constants.CONFIG_DIRS_MODE, os.geteuid(), self.config.strict_permissions)
    (op_fd, existing_filepaths) = self._read_and_append(os.path.join(cp_dir, 'FILEPATHS'))
    idx = len(existing_filepaths)
    for filename in save_files:
        if (filename not in existing_filepaths):
            logger.debug('Creating backup of %s', filename)
            try:
                shutil.copy2(filename, os.path.join(cp_dir, ((os.path.basename(filename) + '_') + str(idx))))
                op_fd.write((filename + os.linesep))
            except IOError:
                op_fd.close()
                logger.error('Unable to add file %s to checkpoint %s', filename, cp_dir)
                raise errors.ReverterError('Unable to add file {0} to checkpoint {1}'.format(filename, cp_dir))
            idx += 1
    op_fd.close()
    with open(os.path.join(cp_dir, 'CHANGES_SINCE'), 'a') as notes_fd:
        notes_fd.write(save_notes)

dataset/ETHPy150Open letsencrypt/letsencrypt/certbot/reverter.py Reverter._add_to_checkpoint_dir/original