{"record":{"id":"2866ba2939731707","repo":"home-assistant/core","slug":"backup-backup-id-not-found-in-agent-agent-id","errorCode":null,"errorMessage":"Backup {backup_id} not found in agent {agent_id}","messagePattern":"Backup (.+?) not found in agent (.+?)","errorType":"exception","errorClass":"BackupManagerError","httpStatus":null,"severity":"error","filePath":"homeassistant/components/backup/manager.py","lineNumber":1408,"sourceCode":"            self.async_on_backup_event(IdleEvent())\n\n    async def _async_restore_backup(\n        self,\n        backup_id: str,\n        *,\n        agent_id: str,\n        password: str | None,\n        restore_addons: list[str] | None,\n        restore_database: bool,\n        restore_folders: list[Folder] | None,\n        restore_homeassistant: bool,\n    ) -> None:\n        \"\"\"Initiate restoring a backup.\"\"\"\n        agent = self.backup_agents[agent_id]\n        try:\n            backup = await agent.async_get_backup(backup_id)\n        except BackupNotFound as err:\n            raise BackupManagerError(\n                f\"Backup {backup_id} not found in agent {agent_id}\"\n            ) from err\n        # Check for None to be backwards compatible with the old BackupAgent API,\n        # this can be removed in HA Core 2025.10\n        if not backup:\n            frame.report_usage(\n                \"returns None from BackupAgent.async_get_backup\",\n                breaks_in_ha_version=\"2025.10\",\n                integration_domain=agent_id.partition(\".\")[0],\n            )\n            raise BackupManagerError(\n                f\"Backup {backup_id} not found in agent {agent_id}\"\n            )\n\n        async def open_backup() -> AsyncIterator[bytes]:\n            return await agent.async_download_backup(backup_id)\n\n        await self._reader_writer.async_restore_backup(","sourceCodeStart":1390,"sourceCodeEnd":1426,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/backup/manager.py#L1390-L1426","documentation":"Raised by BackupManager._async_restore_backup when the selected agent's async_get_backup(backup_id) raises BackupNotFound. The manager resolves the backup through the specific agent chosen for the restore (agent_id), so this means that particular agent does not hold a backup with that ID — even if other agents do.","triggerScenarios":"Calling restore with a backup_id/agent_id pair that does not match: the backup exists on the local agent but the request targets a network agent (or vice versa); the backup was deleted from that agent; a stale UI entry referencing a removed remote backup.","commonSituations":"Backup deleted from the network agent (B2, Google Drive, etc.) while still shown in the UI; agent integrations reloaded/changed so IDs shifted; mixed local/remote backup lists with the wrong agent selected.","solutions":["Refresh the backup list for that agent and restore using the refreshed backup_id, with the agent that actually reports it.","If the backup exists locally only, select the local agent ('backup.local') for the restore.","Verify the agent integration is loaded and can list its backups (its async_list_backups) before restoring."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"agent = manager.backup_agents[agent_id]\nfound = await agent.async_get_backup(backup_id)  # may raise BackupNotFound\n# safer: confirm membership via list\nids = {b.backup_id for b in await agent.async_list_backups()}\nif backup_id not in ids:\n    raise ValueError(f\"{backup_id} not held by {agent_id}\")","typeGuard":null,"tryCatchPattern":"from homeassistant.components.backup.manager import BackupManagerError\n\ntry:\n    await manager.async_restore_backup(backup_id, agent_id=agent_id, ...)\nexcept BackupManagerError as err:\n    if \"not found in agent\" in str(err):\n        holding = [a for a, ag in manager.backup_agents.items()\n                   if backup_id in {b.backup_id for b in await ag.async_list_backups()}]\n        if holding:\n            await manager.async_restore_backup(backup_id, agent_id=holding[0], ...)\n        else:\n            raise\n    raise","preventionTips":["Resolve the holding agent from a fresh list before restoring.","Refresh the UI backup list after deleting remote backups.","Prefer the agent that reported the backup at listing time."],"tags":["backup","restore","not-found","agent-selection"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}