'Prepare database backup record for import.
This method decodes provided backup_url and expects to find the id of
the backup in there.
Then checks the DB for the presence of this backup record and if it
finds it and is not deleted it will raise an exception because the
record cannot be created or used.
If the record is in deleted status then we must be trying to recover
this record, so we\'ll reuse it.
If the record doesn\'t already exist we create it with provided id.
:param context: running context
:param backup_url: backup description to be used by the backup driver
:return: BackupImport object
:raises InvalidBackup:
:raises InvalidInput:'

def _get_import_backup(self, context, backup_url):

    backup_record = objects.Backup.decode_record(backup_url)
    if ('id' not in backup_record):
        msg = _('Provided    backup    record    is    missing    an    id')
        raise exception.InvalidInput(reason=msg)
    kwargs = {'user_id': context.user_id, 'project_id': context.project_id, 'volume_id': IMPORT_VOLUME_ID, 'status': fields.BackupStatus.CREATING, 'metadata': {}}
    try:
        backup = objects.BackupImport.get_by_id(context, backup_record['id'], read_deleted='yes', project_only=False)
        if (backup.status != fields.BackupStatus.DELETED):
            msg = _('Backup    already    exists    in    database.')
            raise exception.InvalidBackup(reason=msg)
        backup.update(kwargs)
        backup.save()
    except exception.BackupNotFound:
        backup = objects.BackupImport(context=context, id=backup_record['id'], **kwargs)
        backup.create()
    return backup
