這是用於管理客戶機器快照的命令。快照記錄客戶計算機的時間點狀態。而後能夠快速恢復到此環境。這可讓你進行試驗和嘗試,並迅速恢復到之前的狀態。安全
快照並非每一個provider都支持的。若是不支持,Vagrant會給你一條錯誤消息。ide
格式:ui
vagrant snapshot push [options] [vm-name]
這將獲取快照並將其推入快照堆棧。this
這是在不須要指定名稱的地方運行vagrant snapshot save命令的簡寫spa
userdeMacBook-Pro:~ user$ vagrant snapshot push -h Usage: vagrant snapshot push [options] [vm-name] Take a snapshot of the current state of the machine and 'push' it onto the stack of states. You can use `vagrant snapshot pop` to restore back to this state at any time. 獲取機器當前狀態的快照,並將其「push」到狀態堆棧上。你可使用「vagrant snapshot pop」命令在任什麼時候候恢復到此狀態。 If you use `vagrant snapshot save` or restore at any point after a push, pop will still bring you back to this pushed state. 若是你在push後的任什麼時候間使用「vagrant snapshot save」或「vagrant snapshot restore」,pop命令仍然會將你帶回這個push狀態。 -h, --help Print this help 打印幫助信息
⚠️若是你使用的是push和pop,請避免使用save和restore,由於混合使用它們是不安全的。vagrant
格式:rest
vagrant snapshot pop [options] [vm-name]
這個命令與vagrant snapshot push命令相反:它將恢復被推送的狀態。code
userdeMacBook-Pro:~ user$ vagrant snapshot pop -h Usage: vagrant snapshot pop [options] [vm-name] --[no-]provision Enable or disable provisioning 啓用或不使用預配置程序 --provision-with x,y,z Enable only certain provisioners, by type or by name. 經過類型或名字來只啓用某些預配置程序 Restore state that was pushed with `vagrant snapshot push`. 恢復使用`vagrant snapshot push`命令推入的狀態 --no-delete Don't delete the snapshot after the restore 恢復後不刪除快照 -h, --help Print this help 打印幫助信息
格式:blog
vagrant snapshot save [options] [vm-name] <name>
這個命令保存了一個新的命名快照。若是使用此命令,則沒法安全使用push和pop子命令。get
userdeMacBook-Pro:~ user$ vagrant snapshot save -h Usage: vagrant snapshot save [options] [vm-name] <name> Take a snapshot of the current state of the machine. The snapshot can be restored via `vagrant snapshot restore` at any point in the future to get back to this exact machine state. 獲取機器當前狀態的快照。快照能夠經過`vagrant snapshot restore`命令在將來的任什麼時候間恢復到這個機器的確切狀態。 Snapshots are useful for experimenting in a machine and being able to rollback quickly. 快照對於在機器中進行試驗和可以快速回滾很是有用。 -f, --force Replace snapshot without confirmation 強制執行 -h, --help Print this help 打印幫助信息
格式:
vagrant snapshot restore [options] [vm-name] <name>
此命令還原指定的快照。
userdeMacBook-Pro:~ user$ vagrant snapshot restore -h Usage: vagrant snapshot restore [options] [vm-name] <name> --[no-]provision Enable or disable provisioning 啓用或不使用預配置程序 --provision-with x,y,z Enable only certain provisioners, by type or by name. 經過類型或名字來只啓用某些預配置程序 Restore a snapshot taken previously with snapshot save. 恢復之前使用snapshot save命令所獲取的快照。 -h, --help Print this help 打印幫助信息
格式:
vagrant snapshot list [options] [vm-name]
這個命令將列出取得的全部快照。
userdeMacBook-Pro:~ user$ vagrant snapshot list -h Usage: vagrant snapshot list [options] [vm-name] List all snapshots taken for a machine. 列舉從機器中獲得的全部快照 -h, --help Print this help 打印幫助信息
格式:
vagrant snapshot delete [options] [vm-name] <name>
這個命令將刪除指定的快照
有些providers要求首先刪除全部「子」快照。vagrant自己並不追蹤這些「子」快照是什麼。若是是這種狀況(例如在VirtualBox中),那麼必須確保以相反的順序刪除快照。
若是機器在快照以前中止,這個快照命令一般會快得多。
若是這不是一個選項,或者不是理想的,那麼刪除也能夠經過大多數providers在線完成。
userdeMacBook-Pro:~ user$ vagrant snapshot delete -h Usage: vagrant snapshot delete [options] [vm-name] <name> Delete a snapshot taken previously with snapshot save. 刪除以前使用with snapshot save命令獲取的快照 -h, --help Print this help 打印幫助信息