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
368 stars 27 forks source link

Backups Not Purging #6

Closed kflinderman closed 4 years ago

kflinderman commented 4 years ago

I'm having a problem where my backups don't seem to be purging. I have a bunch of backups that are well past it's end date. I have even tried using the services tab to auto_backup.purge, but it doesn't seem to do anything. I don't get any logs when I run it with debug logs.

When it does run I get this as well as a completed snapshot:

2020-01-02 21:00:00 DEBUG (MainThread) [custom_components.auto_backup] Creating snapshot AutoBackup: Thu, 9:00 PM (02/01/2020) Version: 0.103.5
2020-01-02 21:00:00 DEBUG (MainThread) [custom_components.auto_backup] New snapshot; command: /snapshots/new/partial, keep_days: 2.0, data: {'name': 'AutoBackup: Thu, 9:00 PM (02/01/2020) Version: 0.103.5', 'password': 'redacted', 'addons': ['core_mariadb', 'core_mosquitto', 'a0d7b954_influxdb', 'a0d7b954_grafana'], 'folders': ['homeassistant', 'share', 'ssl', 'addons/local']}
2020-01-02 21:05:01 ERROR (MainThread) [homeassistant.components.hassio.handler] Timeout on /snapshots/new/partial request
2020-01-02 21:05:01 ERROR (MainThread) [custom_components.auto_backup] Error on Hass.io API: : 

Other than that I don't get any errors whatsoever. It's properly creating my backups though. I followed your generational backup suggestion, but here are my automatons:

https://hastebin.com/veyerohema.sql

and of course this is what I have in my config file:

auto_backup:
  auto_purge: true

If you need more information I'd be willing to send it your way, but don't know what to send.

jcwillox commented 4 years ago

Well I thought I had changed that error to be more specific than "Error on Hass.io API". That error means the backup failed, usually because the API timed out, in that case Hass.io will still create the backup, but the integration won't track it for deletion.

How big are these backups that aren't being purged?

Best option for now is to increase the configuration option backup_timeout it's set to 1200 (20 min) by default.

kflinderman commented 4 years ago

I'll change it up and see if that helps, it does look like most of the backups are "created" at 9:18 for example. I might just set it to 1500 to be safe. I'm also a little surprised (though thinking about it not that surprised). The partials are around 0.49GB and the fulls are 0.51GB. I guess that's what happens when I back up influxdb. Thinking on it, I probably don't need those in the hourly guys.

But yea, I guess I didn't think about the timeout since it had created them successfully. I just assumed it was something else for some reason

kflinderman commented 4 years ago

So, it looks like it is still not purging. I have one that should have expired in 2 days and is 4 days old.

I am now getting this though:

(MainThread) [custom_components.auto_backup] Snapshot create result: {'result': 'ok', 'data': {'slug': '6932762a'}}

And I'm not getting any logs for running auto_backup.purge through the services tab at all. I'm not even sure it's running the purge. I have nothing in the service data section though.

Is there something else I can try?

jcwillox commented 4 years ago

If there is an error during the backup process then the snapshot will not be monitored for deletion. So it's likely those old ones won't ever be deleted. The list of monitored backups is stored under /config/.storage/auto_backup.snapshots_expiry.

The log above ... Snapshot create result: {'result': 'ok' ... means the backup was successful. If you keep getting this message after creating a backup then everything should be working correctly.

auto_backup.purge would create log messages if there were any backups to purge.

I'm currently working on an update, that should be released today, to enhance the error logging, add events and a sensor showing the number of monitored/purgeable backups.

jcwillox commented 4 years ago

I've released the new version 👍 . This has some performance improvements, better logging and the events and sensor should provide you with some extra information. Let me know if you keep having errors with any future backups.

deluxestyle commented 4 years ago

I have the same issue. Still with the newest version 0.4.0

In my logs I see following error messages 2020-01-04 21:20:08 ERROR (MainThread) [homeassistant.components.hassio.handler] Timeout on /snapshots/new/full request 2020-01-04 21:20:08 ERROR (MainThread) [custom_components.auto_backup] Error during backup.

Backup is still created but not monitored.

I've increased already the timeout, but still get the same error my config: auto_backup: auto_purge: true backup_timeout: 4800

The snapshot is around 80 MB

jcwillox commented 4 years ago

Interesting, I believe I've found the issue, the web request to Hass.io had its own 300-second timeout which was occurring well before the backup_timeout. I've removed this timeout now (in 0.4.1) so ... hopefully, this is the last hidden timeout to deal with.

deluxestyle commented 4 years ago

@jcwillox great. Thank you. The backup runs without a error. It shows as well that it is monitored. I guess it’s working now. Thanks for all the hard work

kflinderman commented 4 years ago

Seems to be working now