Vagrantで複数VMに対して個別のスナップショットを作成する
vagrant snapshot save fooで1つのvagrantfile以下の全てのVMに対してスナップショットは作成されるが,全部名前がfooになってわかりにくい.ディレクトリを降りてもダメ.そこで,それぞれに対して別な名前をつけつつ,個別にスナップショットを作成する方法をlog.
save
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. Snapshots are useful for experimenting in a machine and being able to rollback quickly. -h, --help Print this help
と書いてあるので,例えば
. |-- .vagrant | `-- machines | |-- vm1 | `-- vm2 `-- Vagrantfile
のような階層になっていて,それぞれのVMに別個にスナップショットを作成するには
vagrant snapshot save vm1 vm1_ss01 vagrant snapshot save vm2 vm2_ss01
でできる.
restore
リストア時に
vagrant snapshot restore --no-provision vm1 vm1_ss01
のように実行するとプレビジョンを実行せずに復元できる.これも
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. -h, --help Print this help
を参照.