Backup/Restore All Databases In Laravel Homestead

Jacob Graf
Laravel News
Published in
1 min readJul 27, 2015

--

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

--

--

Jacob Graf
Laravel News

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