How to change MariaDB database location to another folder

Hi!

Anyone knows how to move MariaDB database files to another location (ex: Media smb folder)? I just want to save time in making snapshots by avoiding the database backup. I know that MariaDB into Home Assistant is running through a container and I don’t know how to create a symbolic link from a container to outside…

Thank you!

That makes two of us. Also looking for a post or guidance on how to get database into a new folder in config.

I just limited the database in order to be smaller :frowning:
There is something on youtube, about this subject, but it is too complicated…

@PickOne @mr.sneezy
See the last replies from @francisp in the below thread:

1 Like

Done and done, thank you mate.
Sneezy

1 Like

In that post is about the usual database (sqlite), I was talking about moving mariaDB database :slight_smile:

But, here is a tutorial for finding mariaDB database files Home Assistant: MariaDB.. yes I’ll show you where the files are! - YouTube

All you have to do is linking a junction and you are done moving mariadb files

1 Like

Sorry for necroposting, but did you manage to achieve this “link”? I mean of MariaDB database to another (network) folder. I have a usb HDD directly connected on my router and have set this up as shared network storage. I’m trying to use this network HDD for the HA database instead of the SSD directly attached to HA. For the time being I cannot run a different MariaDB server and send my data to it, so I just want to “link” my network storage to HA.
I’ve been trying to bind mount (mount --bind option) the MariaDB database folder to the shared network folder with no luck: There is this file mariadb.err within the MariaDB container, which is a symlink to /proc/1/fd/1. As soon as I bind mount the folders and try to start the container, the initialization of MariaDB container fails with permission errors particularly for this file. Before this happens some files are indeed written on the mounted network HDD. I’ve tried all available mount options and chown etc. variations with no luck…
In general, how can I manage to have the MariaDB database folder outside of the HA environment (eg. change the /datadir of MariaDB)? The necessary file (my.cnf) is not exposed by the volumes of the addon and, if changed, it’s not preserved across container restarts.

I am in almost the same situation and I want to do the same. I simply added the path to my network attached storage, but get an error.
Did you find a solution for this?