That looks like it's exactly what I need, but I'd like anyone to be able to run the vagrant up command to use the Vagrantfile, is there any way to install the plugin when `vagrant up` is run by specifying it in the Vagrantfile?
On Tuesday, March 8, 2016 at 1:16:51 PM UTC, Alvaro Miranda Aguilera wrote: > > hello, > > Seems you can check vagrant-triggers plugin, and run those commands either > before halt or destroy. > > Alvaro. > > On Wed, Mar 9, 2016 at 1:19 AM, Tom Butler <[email protected] <javascript:>> > wrote: > >> I want to be able to store MySQL's data on the host machine using a >> shared folder so when typing vagrant destroy then vagrant up, the data from >> MySQL is retained. This works fine for a httpdocs directory. >> >> >> I managed it in this way: >> >> - Stop the server >> - Copy the original mysql data from /var/lib/mysql to /var/lib/mysql-data >> - Stop the server from running on startup >> - Package the box >> >> Then mount a shared folder, ./mysql (host) to /var/lib/mysql on the guest >> >> and run a provisioning script that, on the guest: >> >> - Copies /var/lib/mysql-data to /var/lib/mysql >> - Starts the server >> >> >> This works fine, *most* of the time. However, sometimes the database gets >> corrupted. I'm not sure why this is but the ibdata1 file gets corrupted and >> becomes unrecoverable. I'm not sure why this is but it must be to do with >> stopping/starting the server and accessing the data folder across a shared >> folder. Obviously this isn't ideal. >> >> To fix this, I created a systemd unit that runs mysqldump and dumps the >> database to /vagrant/database.sql and then changed vagrant to import the >> database in the provisioning script. >> >> The systemd unit works and when shutting down the box without any shared >> folders set up, the database export is created before the server is shut >> down. However, when the .sql file is being written to a shared folder it's >> always zero bytes. I am 90% sure this is because the vagrant halt command >> unmounts the shared folders and sends the shutdown signal. It's likely the >> shared folder is being umounted before the systemd shutdown script is run >> (or at least completed). >> >> Is there any way to avoid this and have it save/load mysql data on the >> host rather than the guest? >> >> -- >> This mailing list is governed under the HashiCorp Community Guidelines - >> https://www.hashicorp.com/community-guidelines.html. Behavior in >> violation of those guidelines may result in your removal from this mailing >> list. >> >> GitHub Issues: https://github.com/mitchellh/vagrant/issues >> IRC: #vagrant on Freenode >> --- >> You received this message because you are subscribed to the Google Groups >> "Vagrant" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/vagrant-up/2aad586a-a7c7-426e-837a-1e98e7a4504a%40googlegroups.com >> >> <https://groups.google.com/d/msgid/vagrant-up/2aad586a-a7c7-426e-837a-1e98e7a4504a%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > -- This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list. GitHub Issues: https://github.com/mitchellh/vagrant/issues IRC: #vagrant on Freenode --- You received this message because you are subscribed to the Google Groups "Vagrant" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/342d33d3-020a-40c0-8fe8-fcee7b7628d9%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
