#Automation to delete backups after x days

1 messages · Page 1 of 1 (latest)

floral path
#

Hi, I'm trying to create an automation to delete a backup after 7 days using a custom service built by chomu https://github.com/chomupashchuk/delete-file-home-assistant.

I managed to make the delete files showing as part of the service method, but when I try to delete the file from the backup folder, it tells me that the folder cannot be found.

My configs below:

service: delete.files_in_folder
data:
  folder: /backup/
  time: 604,800
  only_extensions:
    - .tar

Error:
Error while executing automation automation.daily_backup_housekeeping_1_week: Mandatory key "folder" is missing. @ data['folder']

To add on, I tried declaring the path as both "/backup" and "/backups" and it still didn't work with the same error.

Can someone help me?

prisma tendonBOT
#

To format your text as code, enter three backticks on the first line, press Shift+Enter for a new line, paste your code, press Enter again for another new line, and lastly three more backticks.
```yaml
example: here
```
Don't forget you can edit your post rather than repeatedly posting the same thing.

bold grove
#

It'll help us if you share the whole automation, not a snippet

floral path
#

Sharing the whole automation below:

alias: Daily Backup Housekeeping - 1 week
description: Delete backups after 1 week
trigger:
  - platform: time
    at: "06:00:00"
condition: []
action:
  - service: delete.files_in_folder
    data:
      folder: /backup/
      time: 604800
      only_extensions:
        - .tar
mode: single

What it's supposed to do:
At 6AM everyday, delete backups which was created more than 7 days ago.

bold grove
#

The docs show the path quoted, diid you try that?

#

Same for the file extensions

floral path
floral path
#

Anyone has any advise?