{"record":{"id":"dbb3d85ff38612b8","repo":"home-assistant/core","slug":"error-during-pre-backup-result","errorCode":null,"errorMessage":"Error during pre-backup: {result}","messagePattern":"Error during pre-backup: (.+?)","errorType":"exception","errorClass":"BackupManagerError","httpStatus":null,"severity":"error","filePath":"homeassistant/components/backup/manager.py","lineNumber":512,"sourceCode":"        LOGGER.debug(\"%s platforms loaded in total\", len(self.platforms))\n        LOGGER.debug(\"%s agents loaded in total\", len(self.backup_agents))\n        LOGGER.debug(\"%s local agents loaded in total\", len(self.local_backup_agents))\n        event = BackupPlatformEvent(domain=integration_domain)\n        for subscription in self._backup_platform_event_subscriptions:\n            subscription(event)\n\n    async def async_pre_backup_actions(self) -> None:\n        \"\"\"Perform pre backup actions.\"\"\"\n        pre_backup_results = await asyncio.gather(\n            *(\n                platform.async_pre_backup(self.hass)\n                for platform in self.platforms.values()\n            ),\n            return_exceptions=True,\n        )\n        for result in pre_backup_results:\n            if isinstance(result, Exception):\n                raise BackupManagerError(\n                    f\"Error during pre-backup: {result}\"\n                ) from result\n\n    async def async_post_backup_actions(self) -> None:\n        \"\"\"Perform post backup actions.\"\"\"\n        post_backup_results = await asyncio.gather(\n            *(\n                platform.async_post_backup(self.hass)\n                for platform in self.platforms.values()\n            ),\n            return_exceptions=True,\n        )\n        for result in post_backup_results:\n            if isinstance(result, Exception):\n                raise BackupManagerError(\n                    f\"Error during post-backup: {result}\"\n                ) from result\n","sourceCodeStart":494,"sourceCodeEnd":530,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/backup/manager.py#L494-L530","documentation":"Raised by BackupManager.async_pre_backup_actions when any registered backup platform's async_pre_backup(hass) coroutine raises. The platforms run concurrently with return_exceptions=True; the first Exception found is re-raised wrapped in BackupManagerError with the original as __cause__. It fires before a backup starts, so platforms (e.g., recorder, MariaDB/MySQL integrations) failed their pre-backup preparation (such as pausing writes or flushing).","triggerScenarios":"Starting a backup (async_create_backup) while a pre-backup hook fails — recorder failing to pause/lock the database, a database integration timing out, an addon platform raising, or any custom integration implementing the backup platform incorrectly.","commonSituations":"Recorder on a struggling database (large SQLite file, locked MariaDB); third-party integrations with buggy async_pre_backup; backups failing consistently at 'pre-backup' stage on slow disks.","solutions":["Read the wrapped message — it embeds the underlying platform error (f\"Error during pre-backup: {result}\") which names the real failure.","Check recorder/database health (repair or vacuum the recorder database, verify MariaDB connectivity) and disk space.","Update or fix the integration whose platform raised; disable it temporarily to confirm it is the source.","Retry the backup once transient DB/network issues are resolved."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from homeassistant.components.backup.manager import BackupManagerError\n\ntry:\n    await manager.async_pre_backup_actions()\nexcept BackupManagerError as err:\n    LOGGER.error(\"pre-backup failed: %s (cause: %s)\", err, err.__cause__)\n    abort_backup()","preventionTips":["Keep recorder database healthy (vacuum/repair) before scheduled backups.","Watch the __cause__ of the wrapped error to find the guilty platform.","Fix or disable misbehaving backup platforms before scheduling backups."],"tags":["backup","pre-backup","platform-hook","home-assistant"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}