Persisting mysql data

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.

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

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): WIP: Feature: docker-sync by cytopia · Pull Request #535 · cytopia/devilbox · GitHub

1 Like

Thanks for all the clarification!

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

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: Reddit - Dive into anything

1 Like

Hello there, braindead here, I just upgraded devilbox version and forgot to think about the mysql folder, since I was using devilbox 0.15.
How can I “import” the old mysql folders into the new mysql docker volume?
It seems that the tools available are intended for backups or dumps, but in my case they are not.
Thanks!

Go back to the old version, backup the database, switch to the new version and restore it: https://devilbox.readthedocs.io/en/latest/maintenance/backup-and-restore-mysql.html

2 Likes

I too have the same issue of @masiorama, can you explain in detail how to go back to the older version?

I reverted back to 0.15 by downloading it from the repo, extracted the files and run docker composer up, the installation completed correctly but the databases are not visible in phpmyadmin

If I create a new db, is not visible in the devilbox\data\mysql\mariadb-10.3 , so I suppose that “Docker volume” are active even if I rolled back the devilbox version.

At this point I suppose I can try to move my mysql database into the docker volume (how?) or disable them in order to have mysql data in my windows folder (again how?)

Any help is appreciated, thanks!