hassio-addons / addon-node-red

Node-RED - Home Assistant Community Add-ons
https://addons.community
MIT License
536 stars 125 forks source link

Data not added to snapshots #549

Closed muniter closed 4 years ago

muniter commented 4 years ago

Problem/Motivation

NodeRED not properly backing up

Expected behavior

Each Home Assistant full snapshot should have the nodeRED data backed up.

Actual behavior

On hassio, only the data in /usr/share/hassio/addons/data/a0d7b954_nodered/ is backed up, in my case the only file there is the options.json which is sadly not the flow data.

Steps to reproduce

$ ha snapshots new
# Get slug number from it
$ tar xvf $SLUG.tar
$ tar tvf a0d7b954_nodered.tar.gz 
drwx------    root/root         0        2020-04-25 15:24 ./
-rw-r--r--     root/root        3590    2020-04-25 15:24 ./addon.json
drwxr-xr-x   root/root        0          2020-02-14 23:30 data/
-rw-r--r--     root/root        416     2020-04-25 15:23 data/options.json

Proposed changes

Proper backups :(

Hardware

Running Hassio

Linux ubuserver 4.15.0-96-generic #97-Ubuntu SMP Wed Apr 1 03:25:46 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux Intel(R) Core(TM) i5-4460 CPU @ 3.20GHz 8 Gb RAM

addons-assistant[bot] commented 4 years ago

:wave: Thanks for opening your first issue here! If you're reporting a :bug: bug, please make sure you include steps to reproduce it. Also, logs, error messages and information about your hardware might be useful.

sinclairpaul commented 4 years ago

Please post what you are backing up with your snap. The Node-Red flow data is in the config folder.

frenck commented 4 years ago

☝️ The Node-RED configuration lives in the same configuration folder as Home Assistant. If you backup your configuration of Home Assistant, it will backup the flows as well.

muniter commented 4 years ago

There's something weird going on. Or miss configuration in my part. I just rebuilt my whole setup from scratch moved it to another host, etc.

This is the structure right now (looking at in from the host):

$ pwd
# note the directory we are in which is the same as the config directory
# Is the same directory I get when I ssh into the ssh addon or the hass_cli
/usr/share/hassio/homeassistant
$ ls -l
total 12928
-rw-r--r-- 1 root root     1171 Apr 26 03:06 automations.yaml
-rw-r--r-- 1 root root     3208 Apr 26 00:13 cloud.yaml
-rw-r--r-- 1 root root     8956 Apr 26 02:00 configuration.yaml
drwxr-xr-x 2 root root     4096 Apr 25 22:22 deps
-rw-r--r-- 1 root root        0 Apr 25 22:22 groups.yaml
-rw-r--r-- 1 root root   479913 Apr 26 03:32 home-assistant.log
-rw-r--r-- 1 root root 12627968 Apr 26 03:32 home-assistant_v2.db
# Here is all the flow data stored
drwxr-xr-x 4 root root     4096 Apr 26 03:00 node-red 
# ---------------------------------------------------
-rw-r--r-- 1 root root        0 Apr 25 22:22 scenes.yaml
-rw-r--r-- 1 root root        0 Apr 25 22:22 scripts.yaml
-rw-r--r-- 1 root root      503 Apr 26 00:12 secrets.yaml
drwxr-xr-x 2 root root     4096 Apr 26 01:08 tts
-rw-r--r-- 1 root root      102 Apr 26 01:07 webostv.conf
-rw-r--r-- 1 root root    77824 Apr 26 03:25 zigbee.db

While all the other addons which get properly backed up have it's data in:

$ pwd
# Note where we are in the host
/usr/share/hassio/addons/data
ha@homeassistant:/usr/share/hassio/addons/data$ ls -l
total 32
# Every addon I have installed has it's configuration right here
# And all of them get backed up properly, I create a full snapshot download
# decompress and I get all their configuration and data but not with nodeRED
drwxr-xr-x 2 root root 4096 Apr 26 00:14 a0d7b954_nodered
drwxr-xr-x 3 root root 4096 Apr 26 00:21 a0d7b954_sonweb
drwxr-xr-x 2 root root 4096 Apr 26 00:14 a0d7b954_sqlite-web
drwxr-xr-x 3 root root 4096 Apr 25 23:56 a0d7b954_ssh
drwxr-xr-x 3 root root 4096 Apr 26 00:15 core_almond
drwxr-xr-x 2 root root 4096 Apr 25 23:53 core_check_config
drwxr-xr-x 2 root root 4096 Apr 26 00:14 core_configurator
drwxr-xr-x 2 root root 4096 Apr 26 03:27 core_mosquitto
# Here I list the nodeRED folder and that's all there is
$ ls -l a0d7b954_nodered/
$ -rw-r--r-- 1 root root 409 Apr 26 03:24 options.json
# options.json and when I do a full snapshot that's the only thing 
# that's backed up from node red, none of my flows are backed up.

# All the data that has my flows is in 
$ pwd
/usr/share/hassio/homeassistant/node-red
$ ls -la
total 156
drwxr-xr-x 4 root root  4096 Apr 26 03:00 .
drwxr-xr-x 7 root root  4096 Apr 26 03:43 ..
-rw-r--r-- 1 root root 35479 Apr 26 01:01 .config.json
-rw-r--r-- 1 root root 35231 Apr 26 01:00 .config.json.backup
-rw-r--r-- 1 root root   720 Apr 26 02:59 flows_cred.json
-rw-r--r-- 1 root root   668 Apr 26 02:59 .flows_cred.json.backup
-rw-r--r-- 1 root root 17245 Apr 26 03:24 flows.json
-rw-r--r-- 1 root root 17247 Apr 26 02:59 .flows.json.backup
drwxr-xr-x 3 root root  4096 Apr 26 01:00 lib
-rw-r--r-- 1 root root     2 Apr 26 02:57 node-red-contrib-home-assistant-websocket.json
drwxr-xr-x 2 root root  4096 Apr 26 01:00 nodes
-rw-r--r-- 1 root root   145 Apr 26 01:01 package.json
-rw-r--r-- 1 root root    85 Apr 26 01:01 package-lock.json
-rw-r--r-- 1 root root  7694 Apr 26 01:00 settings.js

I don't know the proccess homeassistant does when backing up, but doesn't seem to me like it's picking up node-red folder in the middle of my config directory.

If I'm not clear, or you have any doubts let me know, I tried my best. As I said this is a new install, new host, new VM, no restoring from previous snapshot, just setting up from zero. And this is the behavior I'm getting

muniter commented 4 years ago

Ok so I just checked and indeed when the snapshot is created. nodeRED data is stored in /config/node-red as declared in the code: https://github.com/hassio-addons/addon-node-red/blob/3b759e48f93d39acda627ead7a5ed6e7b4fc546a/node-red/rootfs/etc/node-red/config.js#L16 So when I create a full snapshot I can get the flow data from extracting the homeassistant.tar.gz which is great!

But I wonder if that hinders the ability of ha to restore only nodeRED if needed as ha has the option: $ ha snapshots restore c1a07617 --addons a0d7b954_nodered Since I would figure that the logic of ha snapshot restore wouldn't know that node-red files are backed up as homeassistant core files. And it would only extract the logical a0d7b954_nodered.tar.gz which has no data but options.json

addons-assistant[bot] commented 4 years ago

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.