I have problems persisting data to the host OS. I have followed this guide: https://www.balena.io/docs/learn/develop/runtime/#persistent-storage and read several post on the forum with no luck.
My project is based on the Google Cloud IoT integration: https://www.balena.io/docs/learn/develop/integrations/google/
and i need to persist certificate files between restarts of my Raspberry Pi
My understanding of how the persistence of data works with the Balena container is that everything placed in the /usr/src/app/data folder of the project will be persisted into the hostOS at /var/lib/docker/volumes/resin-data/_data as my Balena OS version is 2.29.2+rev2 and then be accessible from /usr/src/app/data folder in the container automatically after restart.
So the gist of my bash script generating the certificates is as follows:
#!/bin/bash if [ ! -f ./data/service.json ]; then mkdir -p data echo "$GOOGLE_IOT_SERVICE_JSON" > data/service.json cd data # Create keys openssl req -x509 -newkey rsa:2048 -keyout rsa-priv.pem -nodes -out rsa-cert.pem -subj "//CN=unused" openssl ecparam -genkey -name prime256v1 -noout -out rsa-ec_private.pem openssl ec -in rsa-ec_private.pem -pubout -out rsa-ec_public.pem cd - fi node dist/main.js
However as mentioned, the data is not persisted and new certificates are generated every time the Pi is restarted.
When pushing the project to the Pi I am able to cd to the var/lib/docker/volumes/resin-data/_data folder in the hostOS but it remains empty.
I have attempted pushing from both Windows and mac.
When running the bash script on my dev computer, it works perfectly.
I have assumed it just working out of the box, but is there any settings or configs i need to set before data persistency works?