File are not copied to persistent folder


#1

Hello Guys,

I just started using resin.io and have some problems to copy files to the persistent folder.

If I understand it right I have at application runtime a folder ("/data") which keeps persistent data since it is at least a docker volume which will be mounted at startup.
So coping files at build phase wouldn’t work.

The app I try to run (home assistent) needs a config folder which contains all config-*.yaml files and keeps dynamic data from the app itself.
So the right place for the config folder is under /data

To update my configuration i copy the folder with my config-*.yaml-files
in the build phase to /usr/src/app/hass
and in the startup script I copy everything from /usr/src/app/hass to /data/hass.

But the config files in the /data folder stays in the old state. (timestamp, content not updated, file not copied)

has anybody some hints ?

start.sh

modprobe v4l2_common &

if [ ! -d /data/hass ]; then
    mkdir /data/hass
fi

cp -r /usr/src/app/hass /data/hass

echo "Content SOURCE"
ls -la /usr/src/app/hass

echo "Content DESTINATION"
ls -la /data/hass
echo "SYSTEM UP AND RUNNING ..."

#journalctl -xef

Output after startup:

18.01.18 10:43:00 (+0100) Content SOURCE
18.01.18 10:43:00 (+0100) total 36
18.01.18 10:43:00 (+0100) drwxrwxr-x  6 root root 4096 Jan 18 09:42 .
18.01.18 10:43:00 (+0100) drwxr-xr-x  4 root root 4096 Jan 18 09:41 ..
18.01.18 10:43:00 (+0100) -rw-rw-r--  1 root root  456 Jan 18 09:42 appdaemon.yaml
18.01.18 10:43:00 (+0100) -rw-rw-r--  1 root root    0 Jan 18 09:42 apps.yaml
18.01.18 10:43:00 (+0100) drwxrwxr-x  5 root root 4096 Jan 18 09:42 compiled
18.01.18 10:43:00 (+0100) -rw-rw-r--  1 root root 1980 Jan 18 09:42 configuration.yaml
18.01.18 10:43:00 (+0100) drwxrwxr-x  5 root root 4096 Jan 18 09:42 custom_css
18.01.18 10:43:00 (+0100) drwxrwxr-x 11 root root 4096 Jan 18 09:42 custom_widgets
18.01.18 10:43:00 (+0100) -rw-rw-r--  1 root root    0 Jan 18 09:42 customize.yaml
18.01.18 10:43:00 (+0100) drwxrwxr-x  2 root root 4096 Jan 18 09:42 dashboards
18.01.18 10:43:00 (+0100) -rw-rw-r--  1 root root  270 Jan 18 09:42 secrets.yaml
18.01.18 10:43:00 (+0100) Content DESTINATION
18.01.18 10:43:00 (+0100) total 228
18.01.18 10:43:00 (+0100) drwxrwxr-x  8 root root   4096 Jan 18 09:42 .
18.01.18 10:43:00 (+0100) drwxr-xr-x  3 root root   4096 Jan 17 11:19 ..
18.01.18 10:43:00 (+0100) -rw-r--r--  1 root root      6 Jan 17 11:19 .HA_VERSION
18.01.18 10:43:00 (+0100) -rw-r--r--  1 root root     44 Jan 17 11:21 .uuid
18.01.18 10:43:00 (+0100) -rw-rw-r--  1 root root    464 Jan 17 11:34 appdaemon.yaml
18.01.18 10:43:00 (+0100) -rw-rw-r--  1 root root      0 Jan 17 11:34 apps.yaml
18.01.18 10:43:00 (+0100) drwxrwxr-x  5 root root   4096 Jan 17 11:14 compiled
18.01.18 10:43:00 (+0100) -rw-rw-r--  1 root root   1980 Jan 17 11:34 configuration.yaml
18.01.18 10:43:00 (+0100) drwxrwxr-x  5 root root   4096 Jan 17 11:14 custom_css
18.01.18 10:43:00 (+0100) drwxrwxr-x 11 root root   4096 Jan 17 11:14 custom_widgets
18.01.18 10:43:00 (+0100) -rw-rw-r--  1 root root      0 Jan 17 11:34 customize.yaml
18.01.18 10:43:00 (+0100) drwxrwxr-x  2 root root   4096 Jan 17 11:14 dashboards
18.01.18 10:43:00 (+0100) drwxr-xr-x  4 root root   4096 Jan 17 11:21 deps
18.01.18 10:43:00 (+0100) drwxr-xr-x  6 root root   4096 Jan 17 11:40 hass
18.01.18 10:43:00 (+0100) -rw-r--r--  1 root root    383 Jan 18 09:19 home-assistant.log
18.01.18 10:43:00 (+0100) -rw-r--r--  1 root root 169984 Jan 18 09:42 home-assistant_v2.db
18.01.18 10:43:00 (+0100) -rw-rw-r--  1 root root    274 Jan 17 11:34 secrets.yaml
18.01.18 10:43:00 (+0100) SYSTEM UP AND RUNNING ...

#4

Yes, this is the right overall approach. I think you’ve just got a small bug, where you’re copying the /usr/src/app/hass directory itself into /data/hass, not copying the contents of that directory, which is probably what you want. If you look closely as your destination output, you’ve got a /data/hass/hass folder, which is where your copy is going.

If you change your cp -r to copy from /usr/src/app/hass/* (i.e. copy the contents into /data/hass, not the directory itself), it should do what you want.


#6

Sometimes smallest things makes big differences ^^
Now I works perfectly :wink:

Thanks for your quick help !


#7

Good to hear! Let us know if you have any more trouble.