home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.98k stars 31.03k forks source link

built-in backup failing #126579

Open cdvreede opened 2 months ago

cdvreede commented 2 months ago

The problem

Running a standard backup - with the Google drive add-on. Backup (manual or scheduled kickoff) starts but fails. Partial backup works fine. Had issue earlier but it came good after pruning (purging) the recorder database.

Problem exists when using backup with the google drive add-on as well as the standard backup without add-on. Backup stays in "pending" state - system indicates that the backup took place as the "next backup" schedule is updated.

Recorder database is locked when backup kicks off and remains locked untill HA restart

Upon restart the supervisor logs show errors there where it cannot find the backups that where kicked off but never properly started/ended

the HA core log doesn't seem to contain any detail on the error... home-assistant_2024-09-23T23-31-28.129Z.log

It actually looks like the log stops when the backup start fails - no additional entries are made in the logs until I restart HA

What version of Home Assistant Core has the issue?

core-2024.9.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Backup

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2024-09-24 09:16:48.690 INFO (MainThread) [supervisor.backups.manager] Backup 4a941ee4 starting stage home_assistant
2024-09-24 09:16:58.865 INFO (MainThread) [supervisor.api.middleware.security] /supervisor/info access from cebe7a76_hassio_google_drive_backup
2024-09-24 09:16:58.869 INFO (MainThread) [supervisor.api.middleware.security] /backups access from cebe7a76_hassio_google_drive_backup
2024-09-24 09:16:59.119 ERROR (MainThread) [supervisor.homeassistant.module] Preparing backup of Home Assistant Core failed. Check HA Core logs.
2024-09-24 09:16:59.128 INFO (MainThread) [supervisor.api.middleware.security] /supervisor/logs access from cebe7a76_hassio_google_drive_backup

Additional information

looks like the recorder database gets locked when the backup starts. The recorder DB remains locked - no events recorded - intill I restart HA

After restart the log shows:

Logger: homeassistant.components.recorder.util Source: components/recorder/util.py:299 integration: Recorder (documentation, issues) First occurred: 3:02:17 PM (1 occurrences) Last logged: 3:02:17 PM

The system could not validate that the sqlite3 database at //config/home-assistant_v2.db was shutdown cleanly

Logger: homeassistant.components.recorder.util Source: components/recorder/util.py:630 integration: Recorder (documentation, issues) First occurred: 3:02:17 PM (1 occurrences) Last logged: 3:02:17 PM

Ended unfinished session (id=196 from 2024-09-24 04:40:06.654404)

System Information

version core-2024.9.2
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.12.4
os_name Linux
os_version 6.6.46-haos
arch x86_64
timezone Australia/Sydney
config_dir /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok HACS Data | ok GitHub API Calls Remaining | 5000 Installed Version | 2.0.1 Stage | running Available Repositories | 1481 Downloaded Repositories | 8
AccuWeather can_reach_server | ok -- | -- remaining_requests | 17
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 13.1 -- | -- update_channel | stable supervisor_version | supervisor-2024.09.1 agent_version | 1.6.0 docker_version | 26.1.4 disk_total | 116.7 GB disk_used | 20.5 GB healthy | true supported | true host_connectivity | true supervisor_connectivity | true ntp_synchronized | true virtualization | board | generic-x86-64 supervisor_api | ok version_api | ok installed_addons | Advanced SSH & Web Terminal (19.0.0), Piper (1.5.2), openWakeWord (1.10.0), Whisper (2.1.2), Studio Code Server (5.15.0), ESPHome (2024.9.1), Samba share (12.3.2), Duck DNS (1.18.0), Home Assistant Google Drive Backup (0.112.1), Matter Server (6.5.1)
Dashboards dashboards | 6 -- | -- resources | 1 views | 34 mode | storage
Recorder oldest_recorder_run | September 22, 2024 at 8:21 PM -- | -- current_recorder_run | September 24, 2024 at 3:02 PM estimated_db_size | 222.04 MiB database_engine | sqlite database_version | 3.45.3
Sonoff version | 3.8.1 (ffa7e22) -- | -- cloud_online | 10 / 12 local_online | 10 / 10
vmhq commented 2 months ago

Same here :(

hacscred commented 1 month ago

There's so much noise in your logs that you should first fix the rest of your installation before anyone else looks at this.

prenetic commented 1 month ago

Same here, been happening for me around 2024.07 / 2024.08. It's gotten to the point where I have to accept that 50% of my backup attempts will fail. What's worse is with the database lock not being released upon backup failure I had to automate restarting HAOS five minutes after a backup is requested to forcibly release the lock. Seems multiple people have been running into the same issue around the same timeframe. https://github.com/home-assistant/core/issues/124454

galgabor24 commented 1 week ago

I've had similar issue. I've stopped ha core, deleted the home-assistant_v2.db (via SSH) and started ha core again. I tested the full backup and it's working fine now. My HA is running on a VM in Virtualization Station on my QNAP NAS. I am using OneDrive backup add-on which also wasn't working when I had this error on backups, but since I deleted the home-assistant_v2.db and restarted ha core, OneDrive backup add-on is also seems to be working fine now.

If your HA is on VM, then the location of the db file is: /mnt/data/supervisor/homeassistant/

I hope this will help for someone!