Persisting mysql data

#1

My first post! First of all, thank you for Devilbox. It’s making my entry into docker more “peaceful”. My first question:

I don’t know why mysql data is not persistent in the “data” folder. It was a few days ago, and the only thing I recall doing was trying to make docker-sync work (which I think I did).

However, I’ve tried to start a new project in Devilbox and inside the “data” folder I only have the “www” folder with my htdocs.

In the .env file I’ve checked and I have the following:

###
### Local filesystem path to mysql/mariadb datadir.
###
### This can be an existing mysql data directory or empty.
### If it already is a mysql data directory with content,
### it will be mounted into the docker and used.
###
### If this directory is empty, a new mysql database will be
### created.
###
### Note: Inside this path, a subdirectory with the mysql|mariadb
###       version will be created where the actual data resides.
###       This is to protect databases from being altered by
###       newer or older mysql|mariadb server versions.
###
### Note: When changing this variable you must re-create the container.
###       Simply remove it, it will be auto-created during the next start:
###
### $ docker-compose rm -f
###
HOST_PATH_MYSQL_DATADIR=./data/mysql

However, this is not working, my data mounts shows mysql host path as a “Docker volume”:

2019-03-28_12-48-53_PM

PS: my mysql data seems to be persistent somewhere, but I’d like it to make it persistent inside my project folder.

Thanks!
Bruno.

#2

Searched a bit on GitHub … and this seems like a deliberate move for compatibility reasons. Does it mean this is the way to go from now on? Thanks

#3

Yes this is old and you should recreate your .env file out of env-example

It is as persistent as before, just in a file system location managed by Docker itself.

Yes, this solved many issues on Windows (and maybe also on MacOS at least performance wise).

docker-sync will also end up in the Devilbox during the next feature release. PR is already open (only documentation is missing): https://github.com/cytopia/devilbox/pull/535

1 Like
#4

Thanks for all the clarification!

#5

Sorry, guys but I don’t get it :worried:

I read in the env-example file the HOST_PATH_MYSQL_DATADIR variable is commented out but anyway I tried to use it and it didn’t work.

How can I persist the mysql databases, then?
Is the only way running mysqldump-secure using a shell inside devilbox container?

Thank you in advance.
Regards

#6

This means you have a 0.x version of the Devilbox running. Once the Devilbox reached a mature and stable state with v1.0.0 version, this variable has been removed and all persistent database storage has been migrated to Docker volumes instead.

Rest assured, data is persistent. It is just not mounted to data/mysql/ anymore.

See here for a broader discussion: https://www.reddit.com/r/PHP/comments/az54a2/announcement_devilbox_v0150_and_v100alpha/

1 Like