Image for post
Image for post

Backup/Restore All Databases In Laravel Homestead

Jacob Graf
Jul 27, 2015 · 1 min read

While destroying a Vagrant box can be a necessary evil, dealing with the repercussions of losing all your databases in the process can be a real pain in the butt. Especially if you are developing many sites under a single Homestead box.

I use TextExpander to expand these commands complete with a dynamic timestamp, which is nice. I use ;mysqlb and ;mysqlr as shortcuts to make the process quick and easy.

Be sure you run these commands while ssh’d into your Homestead box or they won't work.

It’s also worth noting that it’s best to run this command from within a shared folder you have setup to be synced with your local machine. In my case, that folder is /home/vagrant/Sites.

Backup All Databases

mysqldump -u homestead -psecret --all-databases > homestead-20150727_0913.sql

Restore All Databases

mysql -u homestead -psecret < homestead-20150727_0913.sql

Laravel News

News and information about the Laravel PHP framework.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store