jcwillox / hass-auto-backup

🗃️ Improved Backup Service for Home Assistant that can Automatically Remove Backups and Supports Generational Backup Schemes.
https://jcwillox.github.io/hass-auto-backup
MIT License
366 stars 27 forks source link

Having issues backups not auto purging #75

Closed benchdog93 closed 1 year ago

benchdog93 commented 2 years ago

Hi, looking for some guidance with auto purge. My attributes monitored and purgeable always show 0 thus auto purge does not work. This is my automation: alias: Perform Daily Backup trigger: platform: time at: "04:00:00" condition: condition: time # Perform backup every day. weekday:

Any help would be greatly appreciated. Thank you Ed

gitrichhub commented 2 years ago

+1

I am having the same issue.

jcwillox commented 2 years ago

I wasn't able to reproduce this issue, and there doesn't seem to be anything wrong with your service calls. You can try creating a bug report and enabling debug logging, it has a section that shows how to do that.

benchdog93 commented 2 years ago

I adjusted from a previous post a test service: auto_backup.backup_partial data: name: Test keep_days: 0.0014 and I get the proper results

I am know seeing a failure error This error originated from a custom integration.

Logger: custom_components.auto_backup Source: custom_components/auto_backup/init.py:333 Integration: Auto Backup (documentation, issues) First occurred: 6:00:00 AM (1 occurrences) Last logged: 6:00:00 AM

Error during backup. Timeout on /backups/new/full request. There may be a backup already in progress.

but the backup has completed.

when i run the template image

So I am a little lost.

ScottG489 commented 2 years ago

I came across this issue because I was having the same problem. After some digging it looks like the issue was that the timeout I have configured auto-backup to use was too short. I haven't yet confirmed increasing the timeout will fix the problem, but due to the error I'm seeing in my logs about a timeout (the same as yours), I believe this will fix the problem.

Basically what's happening is that auto-backup stops monitoring the backups progress after the timeout and just considers it to have failed, even though the backup is still actually in progress and can complete successfully.

I've seen a few issues reported along these lines. I wonder if there's a better way to handle this. Perhaps there's a way to make the monitoring of backups asynchronous? Though if HA's backup creation API is blocking, I'm not sure how this could be accomplished.

Not directly related, but perhaps allowing the user to specify the timeout for each backup individually would be a good idea?

I just checked and some of my backups look like they've taken just shy of 3 hours to finish. My full nightly backups are weighing in at >4GB now.

@jcwillox I see in the documentation you mention:

Increasing this might make Auto Backup less reliable at monitoring backups to delete

Since I'll be increasing it to at least 3 hours, what reliability am I risking by increasing the timeout?

rjenx commented 2 years ago

I too am seeing the timeout error on my daily full back up which starts at 03:30. No other backup is running because I take a partial backup every 6 hours, the last one was at midnight. See below debug logs for the relevant time last night.

This is the partial at midnight: ''' 2022-10-22 00:00:00.037 DEBUG (MainThread) [custom_components.auto_backup] Creating backup (partial); keep_days: 2.0, timeout: 1200, data: {'name': 'Partial_Backup: Sat, 12:00 AM (22/10/2022)', 'addons': [], 'folders': ['homeassistant']} 2022-10-22 00:00:18.720 INFO (MainThread) [custom_components.auto_backup] Backup created successfully: 'Partial_Backup: Sat, 12:00 AM (22/10/2022)' (0d4afafc) 2022-10-22 00:00:18.737 DEBUG (MainThread) [custom_components.auto_backup] Attempting to remove backup: 21796ae8 2022-10-22 00:00:18.746 DEBUG (MainThread) [custom_components.auto_backup] Attempting to remove backup: 91bf679c 2022-10-22 00:00:18.754 INFO (MainThread) [custom_components.auto_backup] Purged 2 backups: ['21796ae8', '91bf679c'] ''' This is the full backup at 03:30: ''' 2022-10-22 03:30:00.012 DEBUG (MainThread) [custom_components.auto_backup] Attempting to remove backup: 6a253db8 2022-10-22 03:30:00.037 INFO (MainThread) [custom_components.auto_backup] Purged 1 backups: ['6a253db8'] 2022-10-22 03:30:00.055 DEBUG (MainThread) [custom_components.auto_backup] Creating backup 'DailyBackup: Saturday, October 22, 2022' 2022-10-22 03:30:00.055 DEBUG (MainThread) [custom_components.auto_backup] Creating backup (full); keep_days: 7.0, timeout: 1200, data: {'name': 'DailyBackup: Saturday, October 22, 2022'} 2022-10-22 03:50:00.056 ERROR (MainThread) [custom_components.auto_backup] Error during backup. Timeout on /backups/new/full request. There may be a backup already in progress. 2022-10-22 03:50:00.059 DEBUG (MainThread) [custom_components.auto_backup] No backups required purging. '''

In the folder I am seeing files for both partial and full backups at the correct times. The full backup has a file time index of 03:50 but no idea whether its corrupted or good.

ScottG489 commented 2 years ago

@rjenx You just need to change the timeout. It's a configuration on the integration itself.

You can see the log with the error is exactly 20 minutes after your backup started and 20 mins is the default timeout. Likely your backups are fine (though you should regularly restore your backups to be sure they're as expected).

Btw, my backup ran last night after increasing the timeout to 3 hours. I can see that it's now being monitored. So increasing the timeout seemed to have worked. I'm still curious what instability I might get from doing this that's mentioned as a possibility in the docs.

rjenx commented 2 years ago

I recently upgraded from a NUC to Home Assistant Yellow, so I guess the processor is a little less powerful. I have increased the timeout so will monitor whether this cures the issue. Thanks for the headsup.

jcwillox commented 2 years ago

Since I'll be increasing it to at least 3 hours, what reliability am I risking by increasing the timeout?

Yeah, the timeouts issue is quite common, the docs site has more information about this. Here's an excerpt:

When using Home Assistant Supervised, Auto Backup must make a request to the Supervisor to create a backup and has to keep that request open until the backup completes, at which point the backups unique id (slug) is returned. This can create stability issues when backups take a long time to create, e.g. 20 minutes+, as the request may fail and Auto Backup will not know the id of the backup to monitor for completion or deletion. In this case, the backup will still be created.

By default, Auto Backup will assume a backup failed if it takes longer than 20 minutes. You can increase this limit using the "Backup Timeout" option, but you may run into reliability issues.

Basically, it may work, but it's uncharted waters.

benchdog93 commented 2 years ago

So hopefully this helps. When I first extended the Backup Timeout to 3hours my system crashed that evening making me take a deeper look. I run HA on a Synology NAS inside a VM which will connect me to the command line and there I saw Influx the cause of my crash, finally figuring out the Influx crash was caused by a few improperly configured nodes in NodeRed. After cleaning them up, deleting all backups manually, reloading Auto Backup, and leaving my Backup Timeout at 3 hrs things have been working as expected the last two days.

My backup is 3.8g and takes just less than 3 hrs to complete.

image

rjenx commented 2 years ago

So extended the timeout and its been running for a few days without issue. Thanks everyone.

Ih8rain2 commented 1 year ago

I have the same issue. The auto-delete doesn’t work so reading this I assume there is a time-out issue. However I can’t find where to adjust it? Can anyone give a hint?

Edit: I found it!

alexboss commented 1 year ago

image

I'm using Hassio Core (Home Assistant 2023.4.6 Supervisor 2023.04.1 Operating System 10.0) and Auto Backup 1.3.2 and the purge is also not working for me (for the daily backups with retention of 7 days and the weekly backup with retention of 28 days).

However, my question is related to the picture above.

Where do you see these sensors?

I only see 1 and nothing related to monitored backups, to purge or failed backups: image

Thank you and best regards.

Alexandre

ScottG489 commented 1 year ago

I believe those are attributes on the main auto backup sensor. I assume they turned those attributes into sensors of their own, but @benchdog93 can verify.

Regarding your purge failure. Look at the attributes and if you have the number of purgeable backups you expect. Also make sure you have a long enough timeout set in the config options for the integration.

alexboss commented 1 year ago

Thanks for your feedback @ScottG489 , but I don't even have these sensors. Gonna create a dedicated issue for this. Best regards.

jcwillox commented 1 year ago

Going to close this issue now as I think it's been sorted out, see this https://github.com/jcwillox/hass-auto-backup/issues/75#issuecomment-1288314210

TLDR: likely a timeout issue, also note that keep_days does not work on download_path, only on /backup.

ScottG489 commented 7 months ago

Btw, for anyone that increased their backup timeouts, you can probably reduce them if you're on HA 2024.2.0 or higher: https://www.home-assistant.io/blog/2024/02/26/home-assistant-os-12-support-for-raspberry-pi-5/#faster-backups

I had my backup timeouts at over 8 hours because influx caused them to take a long time. Now my full backups take only 15 minutes. Really incredible how much faster backups are now. If you're curious, here's some information on how it was sped up: https://github.com/home-assistant/core/pull/110267