Add exclude DB option to backup service call (#101958)

This commit is contained in:
Mike Degatano 2023-10-22 17:40:44 -04:00 committed by GitHub
parent 721c45b7a3
commit c8007b841b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 0 deletions

View File

@ -64,6 +64,7 @@ from .const import (
ATTR_COMPRESSED, ATTR_COMPRESSED,
ATTR_FOLDERS, ATTR_FOLDERS,
ATTR_HOMEASSISTANT, ATTR_HOMEASSISTANT,
ATTR_HOMEASSISTANT_EXCLUDE_DATABASE,
ATTR_INPUT, ATTR_INPUT,
ATTR_LOCATION, ATTR_LOCATION,
ATTR_PASSWORD, ATTR_PASSWORD,
@ -193,6 +194,7 @@ SCHEMA_BACKUP_FULL = vol.Schema(
vol.Optional(ATTR_LOCATION): vol.All( vol.Optional(ATTR_LOCATION): vol.All(
cv.string, lambda v: None if v == "/backup" else v cv.string, lambda v: None if v == "/backup" else v
), ),
vol.Optional(ATTR_HOMEASSISTANT_EXCLUDE_DATABASE): cv.boolean,
} }
) )

View File

@ -16,6 +16,7 @@ ATTR_ENDPOINT = "endpoint"
ATTR_FOLDERS = "folders" ATTR_FOLDERS = "folders"
ATTR_HEALTHY = "healthy" ATTR_HEALTHY = "healthy"
ATTR_HOMEASSISTANT = "homeassistant" ATTR_HOMEASSISTANT = "homeassistant"
ATTR_HOMEASSISTANT_EXCLUDE_DATABASE = "homeassistant_exclude_database"
ATTR_INPUT = "input" ATTR_INPUT = "input"
ATTR_ISSUES = "issues" ATTR_ISSUES = "issues"
ATTR_METHOD = "method" ATTR_METHOD = "method"

View File

@ -58,12 +58,20 @@ backup_full:
example: my_backup_mount example: my_backup_mount
selector: selector:
backup_location: backup_location:
homeassistant_exclude_database:
default: false
selector:
boolean:
backup_partial: backup_partial:
fields: fields:
homeassistant: homeassistant:
selector: selector:
boolean: boolean:
homeassistant_exclude_database:
default: false
selector:
boolean:
addons: addons:
example: ["core_ssh", "core_samba", "core_mosquitto"] example: ["core_ssh", "core_samba", "core_mosquitto"]
selector: selector:

View File

@ -296,6 +296,10 @@
"location": { "location": {
"name": "[%key:common::config_flow::data::location%]", "name": "[%key:common::config_flow::data::location%]",
"description": "Name of a backup network storage to host backups." "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": { "location": {
"name": "[%key:common::config_flow::data::location%]", "name": "[%key:common::config_flow::data::location%]",
"description": "[%key:component::hassio::services::backup_full::fields::location::description%]" "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"
} }
} }
}, },

View File

@ -585,6 +585,7 @@ async def test_service_calls(
{ {
"name": "backup_name", "name": "backup_name",
"location": "backup_share", "location": "backup_share",
"homeassistant_exclude_database": True,
}, },
) )
await hass.async_block_till_done() await hass.async_block_till_done()
@ -593,6 +594,7 @@ async def test_service_calls(
assert aioclient_mock.mock_calls[-1][2] == { assert aioclient_mock.mock_calls[-1][2] == {
"name": "backup_name", "name": "backup_name",
"location": "backup_share", "location": "backup_share",
"homeassistant_exclude_database": True,
} }
await hass.services.async_call( await hass.services.async_call(