Skip to content
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
Closed

add 'vagrant snapshot' option #143

bixu opened this issue Aug 19, 2010 · 36 comments

Comments

@bixu
Copy link

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
Copy link
Contributor

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
Copy link

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
Copy link
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
Copy link

0xAhmed commented Dec 25, 2010

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

@joevandyk
Copy link

  • 1, would love this!

@thbar
Copy link

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
Copy link

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

@BugRoger
Copy link

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

@ryansch
Copy link
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
Copy link

russpos commented Apr 7, 2011

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

@ryansch
Copy link
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
Copy link

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
Copy link

thbar commented Apr 20, 2011

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

@ches
Copy link
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
Copy link

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

@ctrabold
Copy link

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
Copy link
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
Copy link
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
Copy link

+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
Copy link

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

@mitchellh
Copy link
Contributor

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
Copy link

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

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

@josephholsten
Copy link
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.

@mitchellh
Copy link
Contributor

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
Copy link
Contributor

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

@ghost
Copy link

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
Copy link

subscribing. let me know if you find one.

@ctrabold
Copy link

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
Copy link

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
Copy link

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

Won't it work?

@MichaelJCole
Copy link

(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
Copy link

tombh commented Mar 12, 2013

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

@dergachev
Copy link

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

@xiaohanyu
Copy link

+1

@bbhoss
Copy link

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
Copy link

@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.

@ghost ghost locked and limited conversation to collaborators Apr 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests