Backing up home-assistant.log file on restarts

Think i found the culprit. Tried

sudo docker exec -it homeassistant /bin/bash

and in the shell i tried:

cp -r --backup=t /path/to/logfile /path/to/backup/folder

As i see the shell in Hassio HA uses busybox; so the busybox cp command does not have options like ‘–backup=t’. So i entered:

shell_command:
  backup_logs: cp /config/home-assistant.log /config/external_data/

which works like a charm! Now i need to find a way to rename backup log files which is busybox compliant…

Thanks for all your help.

UPDATE:
Solved also the version renaming issue. For future reference, here they are:

shell_command:
  # Backup logs and append a version number if one already exists.
  backup_logs: cp /config/home-assistant.log /config/external_data/log-`date +"%Y%m%d%H%M"`.log
- alias: "Backup Log file"
  trigger:
    platform: homeassistant
    event: shutdown
  action:
    service: shell_command.backup_logs
11 Likes