Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

sunscreem's avatar

Backing up VirtualBox Vagrant and Homestead

I'm runing virtualBox on windows 10. I'm new to this but it seems to be all working okay (albeit slow!).

Any tips on how to backup my VM(s)? I backup my development sites nightly but is there an easy way to back up my VMs? Are the VMs just directories that I can add to the backups?

0 likes
4 replies
otepas's avatar
otepas
Best Answer
Level 13

@sunscreem what I do is slightly different.

For me the development VMs are disposable, and what I have to make sure is that I can recreate it whenever I want.

So what I do is add Vagrantfile to version control, and any permanent changes to the VM are done only via the Vagrantfile. That way, if I have to throw my VM away or re-create my development enviroment in another computer I can do it in minutes.

1 like
sunscreem's avatar

Thank you - that has really helped because you are right, I'm looking at this the wrong way. I shouldn't be thinking about backing up the whole VM - just the files to recreate the VM. Obvious now you say it!

I think I've been put off setting up the VM again as, on my machine here at least, its takes about 15 minutes for the initial setup of homestead. I'm beginning to wonder if the is something in my set up here that is slowing everything down. Even running composer require (on my local machine) takes about 3 minutes to complete.

nyce's avatar

I tend to think that the Original Question is more potent than you give it credit for. In some scenarios, it may be that the data in your database (which is hosted by Homestead) is a necessary part of recovering the environment. Rebuilding a database to contain enough test-worthy data can be a real pain.

Perhaps it's just me who hasn't yet worked out how to script a the DB backup as part of the Vagrant configuration file. But unless this is possible, I don't see the benefit of using Homestead against maintaining any other standard VM.

Cronix's avatar

You can back it up in many ways. I just log into the vm's db using navicat and "backup". In Sequel Pro you can go to "File/Export." You can use any of the normal mysql tools, like mysqldump from the cli.

Why does it have to be "scripted?"

Please or to participate in this conversation.