Delete old snapshots

I have tried several solutions from this forum, but none have worked for me.

Do any of you have a solution to automatically delete snapshots?
Currently I have this:

shell_command:
  delete_old_snapshots: find /backup/* -mtime +2 -exec rm {} \

But when running the service shell_command.delete_old_snapshots I just get this error:

[homeassistant.components.shell_command] Error running command: `find /backup/* -mtime +2 -exec rm {} \`, return code: 1
NoneType: None

For Hassio shouldn’t the path be /config/backup/*?

If I run the command in a shell from the IDE plugin it works.

But I’ll try /config/backup, just to confirm

Same error:

[homeassistant.components.shell_command] Error running command: `find /config/backup/* -mtime +2 -exec rm {} \`, return code: 1
NoneType: None

Had the same problem.

This python script has been working well for me:

You can use this addon (if you’re on Hassio) where you can define when to create it, how many snapshots to maintain and also (if you want) to upload them to Google Drive.

1 Like

The python script have been tested too - not working, unfortunately.

Will definetely test this addon.

Thank you woody - this seems to work like a charm :slight_smile:

1 Like

Any chance you could let me know the errors or problems you were having with the python script? I’m hoping to make it into a good solution for everyone. I realize the addon worked for you so you have no need to change. Just trying to improve the script

Can’t remember the exact error, but the services didn’t work when I tried.

No worries. If you ever try again let me know and I’ll get what ever the bug was fixed.

I looked for the “find” command…

this setup is working for me.

find /backup -name '*.tar' -mtime +30 -exec rm {} \;

HassOS 2.12 - Home Assistant 0.103.0

1 Like

Why do not you use THIS add-on?
It is pretty flexible in configuration…

1 Like

Yeah, also pretty nice.
Now i started to work with this one here. You can turn off the Cloud option and use it just for automatic backups and auto purge.