oncleben31 / home-assistant-config

Ma configuration Home Assistant commentée en anglais et en français | My Home Assistant config with French and English comments.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The backup script complains about argument of the --folders when backing up the mariadb addon and doesn't create backup

0101binary0101 opened this issue · comments

In the backup script.
The mariadb backup doesn't complete correctly on my setup.

time="2021-01-21T23:45:34Z" level=fatal msg="Error while executing rootCmd: flag needs an argument: --folders"

So I commented out the --folders and it works ok

ha addons stop core_mariadb
ha snapshots new --addons core_mariadb --name $(date +"%Y_%m_%d__%H_%M_%S")_core_mariadb # --folders ""
ha addons start core_mariadb

But I've not tried a restore yet.

I've just test and the instruction didn't raised any error:

ha snapshots new --addons core_mariadb --name $(date +"%Y_%m_%d__%H_%M_%S")_core_mariadb --folders ""

Have you some error message and context on your setup ?
The folder option is here to not include any user folders in this snapshot. It's not an issue if you remove it but there is no reason it not works.

@oncleben31

Here's it running and the error message

root@ha01-pi:/usr/share/hassio/share/backup-monitor# docker ps | grep rasp
f8971117f7c2   homeassistant/raspberrypi4-64-homeassistant:2021.1.5   "/init"                  5 days ago    Up 2 hours                                                                        homeassistant
root@ha01-pi:/usr/share/hassio/share/backup-monitor# docker ps | grep mariadb
ccdebf7e8cc3   homeassistant/aarch64-addon-mariadb:2.2.1              "/init"                  5 hours ago   Up 5 hours                                                                        addon_core_mariadb
root@ha01-pi:/usr/share/hassio/share/backup-monitor# cat just-mariadb.sh
# EN: Create partial snapshot for MariaDB only with addon stopped to avoid database corruption
ha addons stop core_mariadb
ha snapshots new --addons core_mariadb --name $(date +"%Y_%m_%d__%H_%M_%S")_core_mariadb --folders ""
ha addons start core_mariadb

root@ha01-pi:/usr/share/hassio/share/backup-monitor#
root@ha01-pi:/usr/share/hassio/share/backup-monitor#
root@ha01-pi:/usr/share/hassio/share/backup-monitor# bash just-mariadb.sh
Command completed successfully.
Error: flag needs an argument: --folders
Usage:
 ha snapshots new [flags]

Aliases:
 new, create, backup

Examples:

 ha snapshots new
 ha snapshots new --addons core_ssh --addons core_mosquitto
 ha snapshots new --folders homeassistant


Flags:
 -a, --addons stringArray    addons to backup, triggers a partial backup
 -f, --folders stringArray   folders to backup, triggers a partial backup
 -h, --help                  help for new
     --name string           Name of the snapshot
     --password string       Password

Global Flags:
     --api-token string   Home Assistant Supervisor API token
     --config string      Optional config file (default is $HOME/.homeassistant.yaml)
     --endpoint string    Endpoint for Home Assistant Supervisor (default is 'supervisor')
     --log-level string   Log level (defaults to Warn)
     --no-progress        Disable the progress spinner
     --raw-json           Output raw JSON from the API

time="2021-01-29T01:23:47Z" level=fatal msg="Error while executing rootCmd: flag needs an argument: --folders"
Command completed successfully.
root@ha01-pi:/usr/share/hassio/share/backup-monitor#

OK thank you. Can you share details on your installation and version used ?

Info was on the last screen ... but here's a different way of viewing it. It's 2021.1.15.. I think the folders just can't be an empty string for release.

root@ha01-pi:/usr/share/hassio/share/backup-monitor# ha core info
arch: aarch64
audio_input: None
audio_output: None
boot: true
image: homeassistant/raspberrypi4-64-homeassistant
ip_address: 172.30.32.1
last_version: 2021.1.5
machine: raspberrypi4-64
port: 8123
ssl: false
update_available: false
version: 2021.1.5
version_latest: 2021.1.5
wait_boot: 600
watchdog: true
root@ha01-pi:/usr/share/hassio/share/backup-monitor#

I can't reproduce on my install:
Capture d’écran 2021-01-30 à 09 03 47

Could it be other part of the install ?
I'm running Home Assistant OS 5.10. And the shell command is run in SSH & Web Terminal (7.8.0) addon.
I didn't succeed to get the version of the ha cli command.

Looks like a bug to me in the cli since a null value "" almost implies that it's invalid and should be one of the values listed.

root@ha01-pi:/usr/share/hassio/backup# ha snapshot new --addons hassio_cli --name test --folders junk
Error: value must be one of ['addons/local', 'homeassistant', 'media', 'share', 'ssl'] @ data['folders'][0]. Got 'junk'
root@ha01-pi:/usr/share/hassio/backup#

I personally wouldn't have a --folders "" it seems a bit nonsensical , the following shows if you did or didn't include a valid argument.

root@ha01-pi:/usr/share/hassio/backup# ha snapshot new --addons hassio_cli --name test
slug: 8250a216
root@ha01-pi:/usr/share/hassio/backup# tar tvf 8250a216.tar
drwx------ root/root         0 2021-01-30 10:51 ./
-rw------- root/root       675 2021-01-30 10:51 ./snapshot.json
root@ha01-pi:/usr/share/hassio/backup# ha snapshot new --addons hassio_cli --name test2 --folders "addons/local"
slug: 8ae619e9
root@ha01-pi:/usr/share/hassio/backup# tar tvf 8ae619e9.tar
drwx------ root/root         0 2021-01-30 10:52 ./
-rw-r--r-- root/root       186 2021-01-30 10:52 ./addons_local.tar.gz
-rw------- root/root       698 2021-01-30 10:52 ./snapshot.json
root@ha01-pi:/usr/share/hassio/backup#

OK initially I was expecting to have smaller archive with the --folder "". I've just made tests and it changes nothing neither the folders included nor the size.
So OK this is useless and seems source of bug in your context I will remove the option of the script.

Thank you for the chat on the topic @0101binary0101