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.

    Jacob Graf

    Written by

    Christian, Husband, Father of 4, Business Owner, Web Designer/Developer, Drummer.

    Laravel News

    News and information about the Laravel PHP framework.

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade