diff --git a/supervisor/addons/addon.py b/supervisor/addons/addon.py index 338e0475a..3a64b82e1 100644 --- a/supervisor/addons/addon.py +++ b/supervisor/addons/addon.py @@ -1322,8 +1322,8 @@ class Addon(AddonModel): arcname="data", ) - # Backup config - if addon_config_used: + # Backup config (if used and existing, restore handles this gracefully) + if addon_config_used and self.path_config.is_dir(): atomic_contents_add( backup, self.path_config, diff --git a/tests/addons/test_addon.py b/tests/addons/test_addon.py index 8c52a25a7..2f8965c88 100644 --- a/tests/addons/test_addon.py +++ b/tests/addons/test_addon.py @@ -446,6 +446,27 @@ async def test_backup( assert await install_addon_ssh.backup(tarfile) is None +@pytest.mark.parametrize("status", ["running", "stopped"]) +async def test_backup_no_config( + coresys: CoreSys, + install_addon_ssh: Addon, + container: MagicMock, + status: str, + tmp_supervisor_data, + path_extern, +) -> None: + """Test backing up an addon with deleted config directory.""" + container.status = status + + install_addon_ssh.data["map"].append({"type": "addon_config", "read_only": False}) + assert not install_addon_ssh.path_config.exists() + install_addon_ssh.path_data.mkdir() + await install_addon_ssh.load() + + tarfile = SecureTarFile(coresys.config.path_tmp / "test.tar.gz", "w") + assert await install_addon_ssh.backup(tarfile) is None + + async def test_backup_with_pre_post_command( coresys: CoreSys, install_addon_ssh: Addon,