New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add 'vagrant snapshot' option #143

Closed
bixu opened this Issue Aug 19, 2010 · 36 comments

Comments

Projects
None yet
@bixu

bixu commented Aug 19, 2010

It would be helpful to allow access to Virtual Box's 'snapshot' feature by allowing a 'vagrant snapshot' command. Associated rollback commands would be even more helpful.

@mitchellh

This comment has been minimized.

Show comment
Hide comment
@mitchellh

mitchellh Aug 25, 2010

Member

Marked as a feature request. I probably won't make this happen by Vagrant 0.6 for a few reasons, but mostly because this will require a lot of thought which I haven't dedicated to it yet. But it is marked for later.

Member

mitchellh commented Aug 25, 2010

Marked as a feature request. I probably won't make this happen by Vagrant 0.6 for a few reasons, but mostly because this will require a lot of thought which I haven't dedicated to it yet. But it is marked for later.

@mikesmullin

This comment has been minimized.

Show comment
Hide comment
@mikesmullin

mikesmullin Oct 8, 2010

ya or at least an easy way to do it via regular virtualbox gui
this is essential. it is one the reasons i am still using straight vbox instead of vagrant.

mikesmullin commented Oct 8, 2010

ya or at least an easy way to do it via regular virtualbox gui
this is essential. it is one the reasons i am still using straight vbox instead of vagrant.

@ches

This comment has been minimized.

Show comment
Hide comment
@ches

ches Nov 8, 2010

Contributor

+1

Just to provide a sample use case, I'm using Vagrant to make localhostin' a little more convenient when developing Chef cookbooks and modeling infrastructure. It would be really nice if Vagrant provided some commands to facilitate easy incremental development so that, for instance, one could:

  1. Take a snapshot after build dependencies are installed
  2. Add an in-progress cookbook/recipe to the run list and vagrant provision
  3. Iterate, possibly rolling back to last snapshot if needed
  4. Once working, trash snapshots to ensure a bottom-up server build still works

Getting to Step 1 may take a long time for package downloads and installations, and no one wants to keep repeating that if working through a problem later in the build that hoses system state so further testing isn't useful or reliable :-)

Contributor

ches commented Nov 8, 2010

+1

Just to provide a sample use case, I'm using Vagrant to make localhostin' a little more convenient when developing Chef cookbooks and modeling infrastructure. It would be really nice if Vagrant provided some commands to facilitate easy incremental development so that, for instance, one could:

  1. Take a snapshot after build dependencies are installed
  2. Add an in-progress cookbook/recipe to the run list and vagrant provision
  3. Iterate, possibly rolling back to last snapshot if needed
  4. Once working, trash snapshots to ensure a bottom-up server build still works

Getting to Step 1 may take a long time for package downloads and installations, and no one wants to keep repeating that if working through a problem later in the build that hoses system state so further testing isn't useful or reliable :-)

@0xAhmed

This comment has been minimized.

Show comment
Hide comment
@0xAhmed

0xAhmed Dec 25, 2010

+1 for implementing this, I almost have the same use case of ches

0xAhmed commented Dec 25, 2010

+1 for implementing this, I almost have the same use case of ches

@joevandyk

This comment has been minimized.

Show comment
Hide comment
@joevandyk

joevandyk Jan 4, 2011

  • 1, would love this!

joevandyk commented Jan 4, 2011

  • 1, would love this!
@thbar

This comment has been minimized.

Show comment
Hide comment
@thbar

thbar Jan 8, 2011

Currently working on a solr chef recipe, I'm using vagrant to make things easier.

Being able to snapshot just before the beginning of the recipe I work on would be really neat, definitely, so +1!

Somewhat slower maybe, maybe there is some way to create a box out of current state ?

thbar commented Jan 8, 2011

Currently working on a solr chef recipe, I'm using vagrant to make things easier.

Being able to snapshot just before the beginning of the recipe I work on would be really neat, definitely, so +1!

Somewhat slower maybe, maybe there is some way to create a box out of current state ?

@kitplummer

This comment has been minimized.

Show comment
Hide comment
@kitplummer

kitplummer Mar 1, 2011

Oh hell yes...give me some of that. I could so use a snapshot/rollback capability right now...

kitplummer commented Mar 1, 2011

Oh hell yes...give me some of that. I could so use a snapshot/rollback capability right now...

@BugRoger

This comment has been minimized.

Show comment
Hide comment
@BugRoger

BugRoger Mar 11, 2011

+1, Snapshots would be really handy. Even a single rollback point would be sweet.

BugRoger commented Mar 11, 2011

+1, Snapshots would be really handy. Even a single rollback point would be sweet.

@ryansch

This comment has been minimized.

Show comment
Hide comment
@ryansch

ryansch Mar 24, 2011

Contributor

I have the same Chef development use case.

I'm having success using vbox snapshots via the VirtualBox GUI. I can take snapshots at any time and I can restore old snapshots after running vagrant suspend. This works as a nice stopgap until vagrant can do this natively.

Contributor

ryansch commented Mar 24, 2011

I have the same Chef development use case.

I'm having success using vbox snapshots via the VirtualBox GUI. I can take snapshots at any time and I can restore old snapshots after running vagrant suspend. This works as a nice stopgap until vagrant can do this natively.

@russpos

This comment has been minimized.

Show comment
Hide comment
@russpos

russpos Apr 7, 2011

Agreed, being able to rollback to set state would be an extremely helpful feature.

russpos commented Apr 7, 2011

Agreed, being able to rollback to set state would be an extremely helpful feature.

@ryansch

This comment has been minimized.

Show comment
Hide comment
@ryansch

ryansch Apr 7, 2011

Contributor

What should a workflow look like?
vagrant up
vagrant snapshot
vagrant rollback

How should we inform vagrant that we'd like it to snapshot before provisioning? After build deps are installed? Other times? Vagrantfile?
Should we handle more than one shapshot? VBox allows you to create an entire snapshot tree.

Then underlying virtualbox gem (https://github.com/mitchellh/virtualbox) looks like it already supports everything we might want to do.

Contributor

ryansch commented Apr 7, 2011

What should a workflow look like?
vagrant up
vagrant snapshot
vagrant rollback

How should we inform vagrant that we'd like it to snapshot before provisioning? After build deps are installed? Other times? Vagrantfile?
Should we handle more than one shapshot? VBox allows you to create an entire snapshot tree.

Then underlying virtualbox gem (https://github.com/mitchellh/virtualbox) looks like it already supports everything we might want to do.

@kitplummer

This comment has been minimized.

Show comment
Hide comment
@kitplummer

kitplummer Apr 8, 2011

I think it would be nice to have a named snapshot.

$ vagrant snapshot mytest

And, if that already exists to append a version to it - mytest.1 or something. Then you'd have to specify that name on the rollback too.

To the second question...maybe just extend the up command to be 'sup', and then provide an argument to specify when the snapshot should happen. 'sup afterpuppet'.

Good stuff.

kitplummer commented Apr 8, 2011

I think it would be nice to have a named snapshot.

$ vagrant snapshot mytest

And, if that already exists to append a version to it - mytest.1 or something. Then you'd have to specify that name on the rollback too.

To the second question...maybe just extend the up command to be 'sup', and then provide an argument to specify when the snapshot should happen. 'sup afterpuppet'.

Good stuff.

@thbar

This comment has been minimized.

Show comment
Hide comment
@thbar

thbar Apr 20, 2011

@ryansch - thanks for the tip on VirtualBox snapshots, I wasn't aware of that!

thbar commented Apr 20, 2011

@ryansch - thanks for the tip on VirtualBox snapshots, I wasn't aware of that!

@ches

This comment has been minimized.

Show comment
Hide comment
@ches

ches Apr 23, 2011

Contributor

Hmm, that's a good question @ryansch -- I was initially just thinking of manual work on the developer's part to edit the run list / manifests executed before/between snapshots, but it might be nice if Vagrant had some smarts built in. I'll give some thought to what a nice workflow might be based on my understanding of how Virtualbox's snapshot capabilities work, perhaps will put some brainstorming in a wiki page and link it from here. If anyone gets around to it first, please share :-)

It could also be interesting/convenient to exploit Virtualbox's ability to set a disk image as immutable, whereby all writes to it are discarded next time the VM is powered on. These can be attached to more than one VM, so might be useful for testing rollout of interdependent cookbooks/roles to a cluster with homogenous base systems.

Contributor

ches commented Apr 23, 2011

Hmm, that's a good question @ryansch -- I was initially just thinking of manual work on the developer's part to edit the run list / manifests executed before/between snapshots, but it might be nice if Vagrant had some smarts built in. I'll give some thought to what a nice workflow might be based on my understanding of how Virtualbox's snapshot capabilities work, perhaps will put some brainstorming in a wiki page and link it from here. If anyone gets around to it first, please share :-)

It could also be interesting/convenient to exploit Virtualbox's ability to set a disk image as immutable, whereby all writes to it are discarded next time the VM is powered on. These can be attached to more than one VM, so might be useful for testing rollout of interdependent cookbooks/roles to a cluster with homogenous base systems.

@joevandyk

This comment has been minimized.

Show comment
Hide comment
@joevandyk

joevandyk May 5, 2011

I've never been able to have vagrant resume from a suspended virtualbox image. it just freezes up. anyone else have that?

joevandyk commented May 5, 2011

I've never been able to have vagrant resume from a suspended virtualbox image. it just freezes up. anyone else have that?

@ctrabold

This comment has been minimized.

Show comment
Hide comment
@ctrabold

ctrabold May 11, 2011

Hi! I came over this issue coincidentally and my immediate thought was: sahara by @jedi4ever

It allows you to enable a sandbox mode within vagrant (think snapshot).

Details / Source: https://github.com/jedi4ever/sahara
Announcement: http://groups.google.com/group/vagrant-up/browse_thread/thread/4c0f0b8501ab2584

ctrabold commented May 11, 2011

Hi! I came over this issue coincidentally and my immediate thought was: sahara by @jedi4ever

It allows you to enable a sandbox mode within vagrant (think snapshot).

Details / Source: https://github.com/jedi4ever/sahara
Announcement: http://groups.google.com/group/vagrant-up/browse_thread/thread/4c0f0b8501ab2584

@ryansch

This comment has been minimized.

Show comment
Hide comment
@ryansch

ryansch May 11, 2011

Contributor

@ctrabold That's a great find! It appears to call out to VBoxManage to work with a single snapshot named sahara-sandbox.

sandbox on - Creates snapshot
sandbox off - Deletes snapshot
sandbox commit - Deletes snapshot and creates a new one with the same name.
sandbox rollback - Powers down vagrant VM, rolls back to snapshot, powers on.

This is simpler than the suggested workflows for native vagrant snapshot support as it only works with a single snapshot but is an excellent stopgap until myself or someone else can find time to implement a fuller feature set.

Contributor

ryansch commented May 11, 2011

@ctrabold That's a great find! It appears to call out to VBoxManage to work with a single snapshot named sahara-sandbox.

sandbox on - Creates snapshot
sandbox off - Deletes snapshot
sandbox commit - Deletes snapshot and creates a new one with the same name.
sandbox rollback - Powers down vagrant VM, rolls back to snapshot, powers on.

This is simpler than the suggested workflows for native vagrant snapshot support as it only works with a single snapshot but is an excellent stopgap until myself or someone else can find time to implement a fuller feature set.

@ryansch

This comment has been minimized.

Show comment
Hide comment
@ryansch

ryansch May 11, 2011

Contributor

@joevandyk: Are you suspending or halting your vagrant VM first? As an alternative try the sahara gem that was just commented on.

Contributor

ryansch commented May 11, 2011

@joevandyk: Are you suspending or halting your vagrant VM first? As an alternative try the sahara gem that was just commented on.

@mariozaizar

This comment has been minimized.

Show comment
Hide comment
@mariozaizar

mariozaizar May 30, 2011

+1 for this feature request. Should be really nice.

$ vagrant snapshot create
[ Vagrant snapshot 20110530 created ]

$ vagrant snapshot go "20110530"
$ vagrant snapshot discard "20110530" 

Or something..

mariozaizar commented May 30, 2011

+1 for this feature request. Should be really nice.

$ vagrant snapshot create
[ Vagrant snapshot 20110530 created ]

$ vagrant snapshot go "20110530"
$ vagrant snapshot discard "20110530" 

Or something..

@BugRoger

This comment has been minimized.

Show comment
Hide comment
@BugRoger

BugRoger May 30, 2011

I'm out of office until the 4th of August. You can contact Torsten Lesmann in case there's problems with WPC.

BugRoger commented May 30, 2011

I'm out of office until the 4th of August. You can contact Torsten Lesmann in case there's problems with WPC.

@mitchellh

This comment has been minimized.

Show comment
Hide comment
@mitchellh

mitchellh Jun 10, 2011

Member

Some great ideas happening here. I just want to let everyone know that I am reading these and will incorporate snapshots in the future, but definitely post-1.0 (not as far away as you think...)

Mitchell

Member

mitchellh commented Jun 10, 2011

Some great ideas happening here. I just want to let everyone know that I am reading these and will incorporate snapshots in the future, but definitely post-1.0 (not as far away as you think...)

Mitchell

@jedi4ever

This comment has been minimized.

Show comment
Hide comment
@jedi4ever

jedi4ever Jun 10, 2011

There is a new plugin called vagrant-snap now by t9md

https://github.com/t9md/vagrant-snap

jedi4ever commented Jun 10, 2011

There is a new plugin called vagrant-snap now by t9md

https://github.com/t9md/vagrant-snap

@josephholsten

This comment has been minimized.

Show comment
Hide comment
@josephholsten

josephholsten Jul 4, 2011

Contributor

I can't tell if jedi4ever is recommending vagrant-snap over sahara, but it seems like the easiest way forward is to bless one of the plugins and merge it in.

Contributor

josephholsten commented Jul 4, 2011

I can't tell if jedi4ever is recommending vagrant-snap over sahara, but it seems like the easiest way forward is to bless one of the plugins and merge it in.

@mitchellh

This comment has been minimized.

Show comment
Hide comment
@mitchellh

mitchellh Jul 4, 2011

Member

Let me quickly make it clear why I have been leaving this issue alone so that people don't think I'm neglecting this for no reason :)

I've wanted for some time for Vagrant to support more than just VirtualBox. I started this work around 6 months back but found that the change necessary would be huge and would introduce instability to an otherwise fairly stable tool, so I decided to punt this feature until post-1.0.

Snapshots are a fairly VirtualBox-specific idea. I'd like to avoid integrating these for now since it would make it harder to support more hypervisors later without saying "Sorry, but not snapshots with X."

I fully intend to bring snapshots in at some point, but for now I'm quite pleased with the plugin ecosystem surrounding it.

Member

mitchellh commented Jul 4, 2011

Let me quickly make it clear why I have been leaving this issue alone so that people don't think I'm neglecting this for no reason :)

I've wanted for some time for Vagrant to support more than just VirtualBox. I started this work around 6 months back but found that the change necessary would be huge and would introduce instability to an otherwise fairly stable tool, so I decided to punt this feature until post-1.0.

Snapshots are a fairly VirtualBox-specific idea. I'd like to avoid integrating these for now since it would make it harder to support more hypervisors later without saying "Sorry, but not snapshots with X."

I fully intend to bring snapshots in at some point, but for now I'm quite pleased with the plugin ecosystem surrounding it.

@mitchellh

This comment has been minimized.

Show comment
Hide comment
@mitchellh

mitchellh Dec 11, 2011

Member

This feature will come eventually, but not for version 1.0. Go with the plugins for now, they work very well.

I'm trying to clean up issues for 1.0 so I'm closing this for now.

Mitchell

Member

mitchellh commented Dec 11, 2011

This feature will come eventually, but not for version 1.0. Go with the plugins for now, they work very well.

I'm trying to clean up issues for 1.0 so I'm closing this for now.

Mitchell

@mitchellh mitchellh closed this Dec 11, 2011

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost May 20, 2012

The plugins for creating snapshots don't seem to be working anymore. Sahara gem works fine but it does not allow multiple snapshots. Anyone know of a plugin that is currently working?

ghost commented May 20, 2012

The plugins for creating snapshots don't seem to be working anymore. Sahara gem works fine but it does not allow multiple snapshots. Anyone know of a plugin that is currently working?

@mikesmullin

This comment has been minimized.

Show comment
Hide comment
@mikesmullin

mikesmullin May 20, 2012

subscribing. let me know if you find one.

mikesmullin commented May 20, 2012

subscribing. let me know if you find one.

@ctrabold

This comment has been minimized.

Show comment
Hide comment
@ctrabold

ctrabold May 20, 2012

I'm using vagrant-snap by @t9md and it works as expected with Vagrant 1.0.3 – even in a multi-vm environment.

This is my Gemfile:

gem "vagrant", "~> 1.0.3"
gem "vagrant-snap", "~> 0.10"

Details: https://github.com/t9md/vagrant-snap

ctrabold commented May 20, 2012

I'm using vagrant-snap by @t9md and it works as expected with Vagrant 1.0.3 – even in a multi-vm environment.

This is my Gemfile:

gem "vagrant", "~> 1.0.3"
gem "vagrant-snap", "~> 0.10"

Details: https://github.com/t9md/vagrant-snap

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost May 28, 2012

Probably some incompatibility with my virtual box version then, or something... With the same Gemfile I can't make it work... Guess I'll stick to sahara for now.

ghost commented May 28, 2012

Probably some incompatibility with my virtual box version then, or something... With the same Gemfile I can't make it work... Guess I'll stick to sahara for now.

@lucaspottersky

This comment has been minimized.

Show comment
Hide comment
@lucaspottersky

lucaspottersky Aug 11, 2012

I'm wondering what happens if you manually take the snapshots in VirtualBox?

Won't it work?

lucaspottersky commented Aug 11, 2012

I'm wondering what happens if you manually take the snapshots in VirtualBox?

Won't it work?

@MichaelJCole

This comment has been minimized.

Show comment
Hide comment
@MichaelJCole

MichaelJCole Nov 4, 2012

(FYI, https://github.com/t9md/vagrant-snap is broken in new versions of vagrant)

vboxmanage can make snapshots if it has the UUID.

The UUID is available from the .vagrant file, and this very fragile code can get it into bash:

UUID=`cat .vagrant | python -c 'import json,sys;obj=json.loads(sys.stdin.read());print obj["'"active"'"]["'"default"'"]'`

This would be easy to off-load if vagrant had a command to get the UUID like: vagrant uuid

UUID=`vagrant uuid`
vboxmanage snapshot $UUID take mysnapshot

VBoxManage snapshot         <uuid>|<name>
                        take <name> [--description <desc>] [--pause] |
                        delete <uuid>|<name> |
                        restore <uuid>|<name> |
                        restorecurrent |
                        edit <uuid>|<name>|--current
                             [--name <name>]
                             [--description <desc>] |
                        list [--details|--machinereadable]
                        showvminfo <uuid>|<name>

MichaelJCole commented Nov 4, 2012

(FYI, https://github.com/t9md/vagrant-snap is broken in new versions of vagrant)

vboxmanage can make snapshots if it has the UUID.

The UUID is available from the .vagrant file, and this very fragile code can get it into bash:

UUID=`cat .vagrant | python -c 'import json,sys;obj=json.loads(sys.stdin.read());print obj["'"active"'"]["'"default"'"]'`

This would be easy to off-load if vagrant had a command to get the UUID like: vagrant uuid

UUID=`vagrant uuid`
vboxmanage snapshot $UUID take mysnapshot

VBoxManage snapshot         <uuid>|<name>
                        take <name> [--description <desc>] [--pause] |
                        delete <uuid>|<name> |
                        restore <uuid>|<name> |
                        restorecurrent |
                        edit <uuid>|<name>|--current
                             [--name <name>]
                             [--description <desc>] |
                        list [--details|--machinereadable]
                        showvminfo <uuid>|<name>
@tombh

This comment has been minimized.

Show comment
Hide comment
@tombh

tombh Mar 12, 2013

I made this simple gist inspired by @MichaelJCole's comment and @t9md's previous efforts.

tombh commented Mar 12, 2013

I made this simple gist inspired by @MichaelJCole's comment and @t9md's previous efforts.

@dergachev

This comment has been minimized.

Show comment
Hide comment
@dergachev

dergachev Apr 22, 2013

If you're running Vagrant 1.1+ and you miss @t9md's vagrant-snap, see https://github.com/dergachev/vagrant-vbox-snapshot

dergachev commented Apr 22, 2013

If you're running Vagrant 1.1+ and you miss @t9md's vagrant-snap, see https://github.com/dergachev/vagrant-vbox-snapshot

@xiaohanyu

This comment has been minimized.

Show comment
Hide comment
@xiaohanyu

xiaohanyu commented Jun 28, 2013

+1

@bbhoss

This comment has been minimized.

Show comment
Hide comment
@bbhoss

bbhoss Sep 27, 2013

This would be so cool to have. Anyone know if there is a way to make this work with the vmware provider?

bbhoss commented Sep 27, 2013

This would be so cool to have. Anyone know if there is a way to make this work with the vmware provider?

@dergachev

This comment has been minimized.

Show comment
Hide comment
@dergachev

dergachev Sep 27, 2013

@bbhoss for VMWare this was recently released: https://github.com/scalefactory/vagrant-multiprovider-snap
Haven't tried it myself but it looks pretty well written.

dergachev commented Sep 27, 2013

@bbhoss for VMWare this was recently released: https://github.com/scalefactory/vagrant-multiprovider-snap
Haven't tried it myself but it looks pretty well written.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment