From c8007b841b5e38f3ccdb8fa1dc7f552b2c4cdfd6 Mon Sep 17 00:00:00 2001 From: Mike Degatano Date: Sun, 22 Oct 2023 17:40:44 -0400 Subject: [PATCH] Add exclude DB option to backup service call (#101958) --- homeassistant/components/hassio/__init__.py | 2 ++ homeassistant/components/hassio/const.py | 1 + homeassistant/components/hassio/services.yaml | 8 ++++++++ homeassistant/components/hassio/strings.json | 8 ++++++++ tests/components/hassio/test_init.py | 2 ++ 5 files changed, 21 insertions(+) diff --git a/homeassistant/components/hassio/__init__.py b/homeassistant/components/hassio/__init__.py index 392671a5471..91b87416c15 100644 --- a/homeassistant/components/hassio/__init__.py +++ b/homeassistant/components/hassio/__init__.py @@ -64,6 +64,7 @@ from .const import ( ATTR_COMPRESSED, ATTR_FOLDERS, ATTR_HOMEASSISTANT, + ATTR_HOMEASSISTANT_EXCLUDE_DATABASE, ATTR_INPUT, ATTR_LOCATION, ATTR_PASSWORD, @@ -193,6 +194,7 @@ SCHEMA_BACKUP_FULL = vol.Schema( vol.Optional(ATTR_LOCATION): vol.All( cv.string, lambda v: None if v == "/backup" else v ), + vol.Optional(ATTR_HOMEASSISTANT_EXCLUDE_DATABASE): cv.boolean, } ) diff --git a/homeassistant/components/hassio/const.py b/homeassistant/components/hassio/const.py index 9b52057a914..193d4762c5a 100644 --- a/homeassistant/components/hassio/const.py +++ b/homeassistant/components/hassio/const.py @@ -16,6 +16,7 @@ ATTR_ENDPOINT = "endpoint" ATTR_FOLDERS = "folders" ATTR_HEALTHY = "healthy" ATTR_HOMEASSISTANT = "homeassistant" +ATTR_HOMEASSISTANT_EXCLUDE_DATABASE = "homeassistant_exclude_database" ATTR_INPUT = "input" ATTR_ISSUES = "issues" ATTR_METHOD = "method" diff --git a/homeassistant/components/hassio/services.yaml b/homeassistant/components/hassio/services.yaml index 33eb1e88ed3..30086e4dd2b 100644 --- a/homeassistant/components/hassio/services.yaml +++ b/homeassistant/components/hassio/services.yaml @@ -58,12 +58,20 @@ backup_full: example: my_backup_mount selector: backup_location: + homeassistant_exclude_database: + default: false + selector: + boolean: backup_partial: fields: homeassistant: selector: boolean: + homeassistant_exclude_database: + default: false + selector: + boolean: addons: example: ["core_ssh", "core_samba", "core_mosquitto"] selector: diff --git a/homeassistant/components/hassio/strings.json b/homeassistant/components/hassio/strings.json index bdd94933b2b..77ef408cafe 100644 --- a/homeassistant/components/hassio/strings.json +++ b/homeassistant/components/hassio/strings.json @@ -296,6 +296,10 @@ "location": { "name": "[%key:common::config_flow::data::location%]", "description": "Name of a backup network storage to host backups." + }, + "homeassistant_exclude_database": { + "name": "Home Assistant exclude database", + "description": "Exclude the Home Assistant database file from backup" } } }, @@ -330,6 +334,10 @@ "location": { "name": "[%key:common::config_flow::data::location%]", "description": "[%key:component::hassio::services::backup_full::fields::location::description%]" + }, + "homeassistant_exclude_database": { + "name": "Home Assistant exclude database", + "description": "Exclude the Home Assistant database file from backup" } } }, diff --git a/tests/components/hassio/test_init.py b/tests/components/hassio/test_init.py index adb462b02e3..c04a26638e6 100644 --- a/tests/components/hassio/test_init.py +++ b/tests/components/hassio/test_init.py @@ -585,6 +585,7 @@ async def test_service_calls( { "name": "backup_name", "location": "backup_share", + "homeassistant_exclude_database": True, }, ) await hass.async_block_till_done() @@ -593,6 +594,7 @@ async def test_service_calls( assert aioclient_mock.mock_calls[-1][2] == { "name": "backup_name", "location": "backup_share", + "homeassistant_exclude_database": True, } await hass.services.async_call(