红联Linux门户
Linux帮助

KVM虚拟机备份和还原之二snapshot

发布时间:2014-08-06 09:42:52来源:linux网站作者:sheismylife

假设已经安装了vm1虚拟机并运行之

创建一个xml文件vm1_snapshot.xml,内容如下:

<domainsnapshot>
<name>vm1_snapshot</name>
<description>Ubuntu 12.10 AMD64 server</description>
</domainsnapshot>


现在运行下面的命令创建vm1的snapshot:

virsh snapshot-create vm1 ./vm1_snapshot.xml
Domain snapshot vm1_snapshot created from './vm1_snapshot.xml'


现在检查一下vm1的snapshot

virsh snapshot-list vm1
Name Creation Time State
------------------------------------------------------------
vm1_snapshot 2012-11-14 14:46:44 +0800 running


现在先登录正在运行的vm1,在/root/下添加一个文件

touch xy

好,用vm1_snapshot来替代现在的vm1(或者说将vm1还原到vm1_snapshot保存的状态)

virsh snapshot-revert vm1 vm1_snapshot

再次登录vm1, /root下没有了xy文件。还原成功。


如果不需要这个vm1_snapshot,可以用下面的命令删除之:

virsh snapshot-delete vm1 vm1_snapshot
Domain snapshot vm1_snapshot deleted
root@host2:~/kvm# virsh snapshot-list vm1
Name Creation Time State
------------------------------------------------------------