Is it possible to force snapshot BEFORE shutdown, using packer?

26 views
Skip to first unread message

William Fernando Oquendo Patiño

unread,
Jun 12, 2021, 10:37:21 AM6/12/21
to Packer
Hi,
I need to create a snapshot of a virtual machine, configured through packer virtualbox-vm, BEFORE the shutdown command. Is it possible? for now I am doing it manually.
This is different to the "target_snapshot" option that runs at the end. I need the snapshot with the machine "turned on".
Thanks in advance for any suggestion.

Dan Linder

unread,
Jun 12, 2021, 4:22:29 PM6/12/21
to Packer
I don’t know of an option in Packer to do exactly that.  If not, you could write up a script to call the API in your VM host to trigger the snapshot.  Then that script could be one of the last builder scripts in the Packer JSON file.

William Oquendo

unread,
Jun 12, 2021, 7:30:59 PM6/12/21
to packe...@googlegroups.com
Hi,
yours is a good idea. I added a provisioner to do that. I was not able to pass the machine name, I put it explicitly, but is working
  "provisioners":
  [
    {
      "type": "shell-local",
      "environment_vars": ["VMNAME={{.Name}}"],
      "inline": ["/usr/local/bin/VBoxManage snapshot base_slack_machine take 'After slackware package install'"]
    }
  ]
Thank you!

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to a topic in the Google Groups "Packer" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/packer-tool/RMzia5rHEaA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/9c0fb0ec-7e88-482f-968c-6b27e2f68259n%40googlegroups.com.


--

Best regards / Cordialmente,

William-Fernando Oquendo
--------------------------
Este correo puede carecer de tildes o eñes debido al teclado. 

Reply all
Reply to author
Forward
0 new messages