Support the ongoing development of Laravel.io →
Installation Configuration Database
Last updated 2 years ago.
0

There was a post on here in the last few days / week (I think) about backing up your Vagrant DB and restoring it again afterwards. Have a little search, it should come up.

0

I did search around and couldn't find an answer before I asked. I double checked and searched again but can't seem to find that thread. At any rate, I was hoping to find something more automated. I don't want to manually have to run a command to backup my vagrant database, I wan't it to sync to my local machine.

I did this with Mamp, I put my actual DB files in my Google Drive and then symlinked to them. That way if my computer crashed and I had to start from scratch, literally everything is on Google Drive.

I was hoping to be able to map (symlink) my DB on Vagrant to a folder in my local machine (if that's possible) to achieve automated real time backup.

0

Update (but still not working)

I decided to copy the /var/lib/mysql directory to my local machine under /Google Drive/Sites/vagrant-mysql.

I then moved the /var/lib/mysql to /var/lib/mysqlold and halted and re-upped vagrant.

However, the mapping gave the user and group to "vagrant" and the wrong permissions on the folder. So I had to change them in the terminal and then start the mysql service.

It worked great for reads but not for writes.

So, I undid all my changes.

My next step (for anyone reading this that wants an automated solution) will be to look at the vagrantfile itself. I can map directly in there and assign a user:group (mysql:mysql) and give the folder the proper permissions (as well as the proper permissions on my local machine). I think that will let me have the solution I am looking for of a 100% automated sync/backup of my database files.

This also allows to be able to work seamlessly on my work and home computers without having to git commit when I go between the 2. Google Drive (or Dropbox if you prefer) keeps everything in sync for me.

0

Hello,

Any update to this? interested in the same thing using homestead.

thanks!

0

eckenroed said:

I was curious if there is a way using Vagrant (or Homestead) to have your DB files work like your PHP files. In other words, I would love to map my MySQL directory in the Vagrant virtual machine back to a folder on my local hard drive (within Google Drive). This way my data is independent of my Vagrant installation.

Essentially if I get a new Mac in the next few month's, I would love to just sync up my Google Drive, install a clean vagrant, re-map the file, then vagrant up and have my database still be there.

Is this possible? Am I thinking about this problem wrong? Is this not a problem and I just don't have the proper understanding of Vagrant?

Well.. the easiest for me was just to install MySQL locally, and then connect my homestead Laravel installations to that.... I don't have to SSH into the homestead box, and I can destroy the vagrant box anytime without any problems or additional work whatsoever :).

I originally did it because I needed a higher MySQL version than homestead provided, but doing it means you can run exactly the version of MySQL that you use in production, and you can update homestead anytime. You might want to try it.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

eckenroed eckenroed Joined 28 Mar 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.