Databases and vagrant

554 views
Skip to first unread message

Lee Marrett

unread,
Jun 9, 2014, 5:51:47 PM6/9/14
to wordpress-...@googlegroups.com
Hey there,

forgive me if this is a dumb question. I've been trying to find a definitive answer somewhere but I can't, which leads me to believe i'm not quite seeing something I should be.

I'm trying to figure out how best to work with databases and vagrant. Up til now, my work with vagrant has just been static and or javascript/json based so i've not had to deal with databases in this way. Now however I'm working in wordpress it becomes a little more critical; i don't want to waste my time repeating myself.

Once I've installed wordpress and added some content into the site, how do i make sure I don't lose the content in the database? 

If I do some work and then call "vagrant halt" that doesn't do away with the box, but if I use "vagrant destroy" that kills the database and the content inside it completely, right?

My development environment makes use of Bittorrent sync so if I need to work on my laptop I can. However each time I switch from my desktop to my laptop and use "vagrant up" it provisions the machine again (i think) -- that obviously means the database work gets wiped, but I don't know how to make sure that gets carried across, short of exporting the database on a regular basis and putting it into a shared folder to import on the other machine.

Sorry if that's a bit longwinded. Any help would be really appreciated!

Cheers

Lee

Simon Wheatley

unread,
Jun 10, 2014, 10:36:27 AM6/10/14
to Lee Marrett, wordpress-...@googlegroups.com
Hi Lee,

Others can fill you in more detail, but essentially the databases are on drives which are held within the virtual machine. So the database files ARE destroyed when a VM is destroyed.

HOWEVER… there is a script which runs on vagrant destroy (and halt, and suspend) which backs up the DB, it's here:

Note you can have custom versions of that script, so you can get the DB backups somewhere you can sync them to your other dev environment.


Hope this helps.

Cheers,

Simon




--
You received this message because you are subscribed to the Google Groups "WordPress and Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wordpress-and-va...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Lee Marrett

unread,
Jun 11, 2014, 6:36:22 AM6/11/14
to wordpress-...@googlegroups.com, leema...@gmail.com
Brilliant, thanks so much Simon.

Pretty much confirmed my suspicions, which led me to further investigate VVV only to see this issue of mine is pretty much taken care of out of the box!

VVV creates a synced folder for those database dumps you mentioned so it's all handled without me having to worry about a thing. Which is kind of cool and also kind of scary ;)

Thanks again!

Rafał Gicgier

unread,
Feb 9, 2015, 10:06:16 AM2/9/15
to wordpress-...@googlegroups.com, leema...@gmail.com
Hello Lee,

I found this conversation while having some trouble with the Vagrant.

Actually Simon's answer is missing some important thing. Within the file pointed by him, there's a note above: http://screencast.com/t/XBluac3Sps1r that the databases need to exist for the migration process to work properly. Which means you would need to manually specify each database you had created within the database/import-custom.sql file.

See more at: https://github.com/Varying-Vagrant-Vagrants/VVV/blob/master/database/import-sql.sh

Posting this in case someone else had encountered the same issue.

Cheers,
Rafal
Reply all
Reply to author
Forward
0 new messages