仙道彰
作者仙道彰·2018-06-21 16:56
数据库开发工程师·花旗集团

虚拟机备份和恢复 ---IBM 官方文档

字数 4694阅读 1153评论 1赞 3

Backup and Restore Kernal-Based Virtual Machines 《IBM 官方教程》

This topic provides instructions to backup and restore a Kernel-based virtual machine (KVM) in RHEL Open Client.

Note: It is recommended that you shut down all running virtual machines in your system before beginning this process to ensure you have enough space available on your backup media.

**Backup a KVM
Restore a KVM
Restore the Desktop Shortcut**

Backup a KVM

1. Open a terminal. Click Computer, More Applications, then Terminal.
2.Use the sudo - command to become the root user.

[IBM User ~]$ sudo -s
[sudo] password for IBM User:

3.Change to the "/etc/libvirt/qemu" directory.

[root IBM User]# cd /etc/libvirt/qemu
[root qemu]#

4.Show all availabe KVM image configuration files. In the example below, three virtual machines are available.

[root qemu]# ls -l
total 40
drwx------. 3 root root 4096 May 29 11:21 networks
-rw-rw-r--. 1 root root 4622 Jun 4 07:44 Virtual_Client_for_Linux_Windows_7-2014-02-28-g-KVM.xml
-rw-rw-r--. 1 root root 4622 Jun 4 07:44 Virtual_Client_for_Linux_Windows_7-2014-03-27-w-KVM.xml
-rw-rw-r--. 1 root root 4596 Jun 4 07:44 Virtual_Client_for_Linux_Windows_7-KVM.xml

5.Copy the desired XML file from the above list to the back-up location. (The back-up location used in this example is "/home/IBM User," but you can use a different location.)

[root qemu]# cp Virtual_Client_for_Linux_Windows_7-KVM.xml /home/IBM User/

6.The corresponding image file is located in the directory "/var/lib/libvirt/images." Open the directory.

[root qemu]# cd /var/lib/libvirt/images/
[root images]#

7.Show all KVM image files. You should see the same names as above.

[root images]# ls -l
-rw-r--r--. 1 root root 32217432064 Feb 28 12:32 Virtual_Client_for_Linux_Windows_7-2014-02-28-g-KVM.qcow2
-rw-rw-r--. 1 root root 10 Feb 28 12:00 Virtual_Client_for_Linux_Windows_7-2014-02-28-g-KVM.qcow2.type
-rw-r--r--. 1 root root 32217432064 Mar 27 13:28 Virtual_Client_for_Linux_Windows_7-2014-03-27-w-KVM.qcow2
-rw-rw-r--. 1 root root 10 Mar 27 13:19 Virtual_Client_for_Linux_Windows_7-2014-03-27-w-KVM.qcow2.type
-rw-r--r--. 1 root root 32217432064 Mar 20 06:53 Virtual_Client_for_Linux_Windows_7-KVM.qcow2
-rw-rw-r--. 1 root root 10 Jan 22 07:04 Virtual_Client_for_Linux_Windows_7-KVM.qcow2.type

8.Copy the files corresponding to the XML file copied above to the back-up location.

[root images]# cp Virtual_Client_for_Linux_Windows_7-KVM.qcow2 /home/IBM User/

9.Switch back to your normal user by using the exit command.

[root images]# exit
exit
[IBM User ~]$

10.Change to the Desktop directory inside your home directory by using the cd ~/Desktop command.

[IBM User ~]$ cd ~/Desktop/
[IBM User Desktop]$

11.Finally, copy the desktop shortcut to the back-up location.

[IBM User Desktop]$ cp Virtual_Client_for_Linux_Windows_7-KVM-virt-manager.desktop /home/IBM User/
[IBM User Desktop]$

Now the KVM is backed up.

Restore a KVM

1. Open a terminal. Click Computer, More Applications, then Terminal.
2.Use the sudo -s command to become the root user.

[IBM User ~]$ sudo -s
[sudo] password for IBM User:
[root IBM User]#

3. Change to the back-up directory. (The backup location used in this example is "/home/IBM User" but you should enter your back-up location.)

[root IBM User]# cd /home/IBM User

4.Copy the XML file from the virtual machine to the "/etc/libvirt/qemu/" directory.

[root IBM User]# cp Virtual_Client_for_Linux_Windows_7-KVM.xml /etc/libvirt/qemu/
cp: overwrite `/etc/libvirt/qemu/Virtual_Client_for_Linux_Windows_7-KVM.xml'? y
[root IBM User]#

5.Copy the QCOW2 file back to the "/var/lib/libvirt/images" directory.

[root IBM User]# cp Virtual_Client_for_Linux_Windows_7-KVM.qcow2 /var/lib/libvirt/images/
cp: overwrite `/var/lib/libvirt/images/Virtual_Client_for_Linux_Windows_7-KVM.qcow2'? y

6.Switch back to your normal user by using the exit command.

[root Desktop]# exit
exit
[IBM User ~]$

7.Copy the desktop shortcut back to the "~/Desktop" directory.

[IBM User ~]$ cp Virtual_Client_for_Linux_Windows_7-KVM-virt-manager.desktop ~/Desktop/

8.Restart "libvirtd" to apply the configurations change.

[IBM User ~]$ sudo service libvirtd restart
[sudo] password for IBM User:
Stopping libvirtd daemon: [ OK ]
Starting libvirtd daemon: [ OK ]

Now the KVM should be restored.

Restore the Desktop Shortcut

If the desktop shortcut has been lost, it can be recreated using the following steps.

1.Click Computer, then More Applications.
2.On the left side, click System Tools, then IBM Virtual Machine Manager.
3.Select the virtual machine from the list and press the Launch button.
4.In the IBM Virt Viewer (the window with the virtual machine), select Actions, then click "Create Shortcut on Desktop."

声明:版权所有非经授权请勿做任何商业用途,仅限技术交流; 转载请注明出处,谢谢;

如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!

3

添加新评论1 条评论

wuwenpinwuwenpin软件开发工程师南京
2018-06-21 21:21
感谢分享
Ctrl+Enter 发表

作者其他文章

相关文章

相关问题

相关资料

X社区推广