{"record":{"id":"87b8dace83349579","repo":"home-assistant/core","slug":"failed-to-create-dir-tar-file-path-parent-err","errorCode":null,"errorMessage":"Failed to create dir {tar_file_path.parent}: {err} ({err.__class__.__name__})","messagePattern":"Failed to create dir (.+?): (.+?) \\((.+?)\\)","errorType":"exception","errorClass":"BackupReaderWriterError","httpStatus":null,"severity":"error","filePath":"homeassistant/components/backup/manager.py","lineNumber":1907,"sourceCode":"                raise BackupManagerExceptionGroup(\n                    f\"Multiple errors when creating backup: {unhandled_exc}, {err}\",\n                    [unhandled_exc, err],\n                ) from None\n\n    def _mkdir_and_generate_backup_contents(\n        self,\n        backup_data: dict[str, Any],\n        database_included: bool,\n        password: str | None,\n        tar_file_path: Path | None,\n    ) -> tuple[Path, int]:\n        \"\"\"Generate backup contents and return the size.\"\"\"\n        if not tar_file_path:\n            tar_file_path = self.temp_backup_dir / f\"{backup_data['slug']}.tar\"\n        try:\n            make_backup_dir(tar_file_path.parent)\n        except OSError as err:\n            raise BackupReaderWriterError(\n                f\"Failed to create dir {tar_file_path.parent}: \"\n                f\"{err} ({err.__class__.__name__})\"\n            ) from err\n\n        excludes = EXCLUDE_FROM_BACKUP\n        if not database_included:\n            excludes = excludes + EXCLUDE_DATABASE_FROM_BACKUP\n\n        def is_excluded_by_filter(path: PurePath) -> bool:\n            \"\"\"Filter to filter excludes.\"\"\"\n\n            for exclude in excludes:\n                # The home assistant core configuration directory is added as \"data\"\n                # in the tar file, so we need to prefix that path to the filters.\n                if not path.full_match(f\"data/{exclude}\"):\n                    continue\n                LOGGER.debug(\"Ignoring %s because of %s\", path, exclude)\n                return True","sourceCodeStart":1889,"sourceCodeEnd":1925,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/backup/manager.py#L1889-L1925","documentation":"BackupReaderWriterError raised when creating the backup destination directory (make_backup_dir on tar_file_path.parent) fails with an OSError. The backup manager could not create the directory that should hold the .tar file, so nothing can be written.","triggerScenarios":"OSError (PermissionError, ReadOnlyFileSystemError, FileNotFoundError on a missing parent, disk issues) from make_backup_dir for the backup temp/output directory (default: the local backup dir under config, or temp_backup_dir).","commonSituations":"Backup directory on a read-only mount; container user lacks write permission on /config/backups or the temp dir; configured local agent path points to an unmounted/unplugged USB drive; disk full or quota exceeded.","solutions":["Check permissions/ownership of the backup and temp directories for the user HA runs as (e.g. chown, or fix the Docker volume mount read-only flag)","Verify the target filesystem is mounted and writable (touch a file in the directory as the HA user)","Free disk space / raise the quota","If using a custom local agent path, confirm the path exists and is writable"],"exampleFix":"# before: read-only or wrong-owner backup dir\n$ ls -ld /config/backups  # drwxr-xr-x root root\n# after\n$ chown -R homeassistant:homeassistant /config/backups\n$ chmod u+w /config/backups","handlingStrategy":"validation","validationCode":"import os\nbackup_dir = str(tar_file_path.parent)\nassert os.path.isdir(backup_dir) and os.access(backup_dir, os.W_OK), f\"backup dir not writable: {backup_dir}\"","typeGuard":null,"tryCatchPattern":"try:\n    make_backup_dir(path.parent)\nexcept OSError as err:\n    raise BackupReaderWriterError(f\"cannot create {path.parent}: {err}\") from err","preventionTips":["Pre-flight check write permissions on the backup and temp directories as the HA user","Mount backup volumes read-write in docker-compose","Alert on low disk space before scheduled backups"],"tags":["home-assistant","backup","filesystem","permissions"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}