Exclude userdata folders from automatic backup

Hi openHAB community.

I’m running openHAB as a docker container right now using the 4.0.0 snapshot tag, and I keep the container updated using watchtower.

My problem is that I’m testing a Speech-to-Text local add-on and I’m placing the model files in its respective folder under the oh userdata folder, that causes my backup to be enormous as it contains all the models I have there for testing. And now that I’m using the snapshot tag, that happens every night.

I think Is not a big problem, because the majority of the users will not face this as they will no use the snapshot tags, or use automatic updates, but I would like to know if there is already a way to exclude folders into the userdata directory from been backup.

Thank you in advance.

What is the command that you use to create a backup ? Is it openhab-cli backup ?
In case it is have a look at the script that is called backup which is called from within openhab-cli.
backup contains script code lines:

if [ -z "$INCLUDE_CACHE" ]; then
  find "${OPENHAB_USERDATA:?}/"* -prune -not -path "${OPENHAB_BACKUPS:?}" -and -not -path '*/tmp' -and -not -path '*/cache' | xargs -I % cp -R % "$TempDir/userdata"
  find "${OPENHAB_USERDATA:?}/"* -prune -not -path "${OPENHAB_BACKUPS:?}" | xargs -I % cp -R % "$TempDir/userdata"

So you could try to add -and -not path YourPathHere to exclude YourPathHere from being part of the backup.zip file.
Doing this change will result in you have to do it again after every update that overwrites your changes.
So this seems not to be a good option. There is no switch to describe directories that are to be excluded.

Have you considered to move model files somewhere else ?

1 Like

Thank you for the response, not sure what backup is used, is the backup that happen in the docker image on upgrade, but I can look at it, and try the solution you suggested, it seems promising.

Already though on using a different folder, the problem I think is that it will make everything harder to configure, I can assume that the userdata folder has already the correct permissions, exists, it’s mounted to a persistent storage in case of running on docker, so doing that seems like will complicate the setup. while having an easy way to exclude folders or file types from the backup sounds like a simpler thing to me.

Thank you again for the guidance, for now I will look at it to see if I can solve my situation.