Vagrant

説明

saharaよりもおおまかに全体のスナップショットを複数取得するのに便利なプラグインです。

プラグインのインストール

$ vagrant plugin install vagrant-vbox-snapshot

スナップショットの取得

$ vagrant snapshot take <snapshot-name>

直前のスナップショットの復元

$ vagrant snapshot back

任意のスナップショットの復元

$ vagrant snapshot go <snapshot-name>

スナップショットの削除

$ vagrant snapshot delete <snapshot-nam>

スナップショットの一覧表示

$ vagrant snapshot list

スナップショットの取得

VagrantのVMが稼働している状態でもすぐに取得完了できました。

MacBook-Pro:centos5-1 hogehoge$ vagrant snapshot list
Listing snapshots for 'default':
This machine does not have any snapshots

MacBook-Pro:centos5-1 hogehoge$ vagrant snapshot take centos5-1-1st
Taking snapshot centos5-1-1st
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Snapshot taken. UUID: f9e4367b-6e6b-4f99-8b75-1b4c75186e7f
MacBook-Pro:centos5-1 hogehoge$ vagrant snapshot list
Listing snapshots for 'default':
  Name: centos5-1-1st (UUID: f9e4367b-6e6b-4f99-8b75-1b4c75186e7f) *

スナップショットの復元(リストア)

VagrantのVMが稼働している状態でもリストアは可能ですが、再起動するので、SSH接続しているセッションは切断されます。

MacBook-Pro:centos5-1 hogehoge$ vagrant snapshot list
Listing snapshots for 'default':
  Name: centos5-1-1st (UUID: f9e4367b-6e6b-4f99-8b75-1b4c75186e7f) *

MacBook-Pro:centos5-1 hogehoge$ vagrant snapshot go centos5-1-1st
Powering off machine 3d2b982b-1ee1-4358-a30c-77fa84663589
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Restoring snapshot f9e4367b-6e6b-4f99-8b75-1b4c75186e7f
Starting restored VM
==> default: Resuming suspended VM...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
   default: SSH address: 127.0.0.1:2222
   default: SSH username: vagrant
   default: SSH auth method: private key
   default:
   default: Vagrant insecure key detected. Vagrant will automatically replace
   default: this with a newly generated keypair for better security.
   default:
   default: Inserting generated public key within guest...
   default: Removing insecure key from the guest if it's present...
   default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!

備考

マルチマシン設定をしている場合は、VM名を指定することでスナップショットが取得可能です。
※指定しないと"This command requires a specific VM name to target in a multi-VM environment."と表示されてエラーになります。

$ vagrant snapthot list vm1
$ vagrant snapshot take vm1 test

参考URL:http://qiita.com/succi0303/items/e06bca7db5a0c3de96af


トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2022-06-30 (木) 01:40:11