zoukankan      html  css  js  c++  java
  • External (and Live) snapshots with libvirt

    list all the block devices associated with the guest

    $ virsh domblklist testvm --details
    Type       Device     Target     Source
    ------------------------------------------------
    file       disk       vda        /export/vmimgs/testvm.qcow2

    let’s create a snapshot(disk-only) of the guest

    $ virsh snapshot-create-as testvm snap1-testvm "snap1 description" 
      --diskspec vda,file=/export/vmimgs/snap1-testvm.qcow2 
      --disk-only --atomic

    – ‘–atomic’ just ensures either the snapshot is run completely or fails w/o making any changes

    $ qemu-img info /export/vmimgs/snap1-testvm.qcow2 
    image: /export/vmimgs/snap1-testvm.qcow2
    file format: qcow2
    virtual size: 20G (21474836480 bytes)
    disk size: 2.5M
    cluster_size: 65536
    backing file: /export/vmimgs/testvm.qcow2
    $ 

    created 2 more snapshots

    $ virsh snapshot-list testvm --tree
    
    snap1-testvm
      |
      +- snap2-testvm
          |
          +- snap3-testvm
            

    image file chain[ base<-snap1<-snap2<-snap3 ]:

    #--------------------------------------------#
    $ qemu-img info /export/vmimgs/snap3-testvm.qcow2
    image: /export/vmimgs/snap3-testvm.qcow2
    file format: qcow2
    virtual size: 20G (21474836480 bytes)
    disk size: 129M
    cluster_size: 65536
    backing file: /export/vmimgs/snap2-testvm.qcow2
    #--------------------------------------------#
    $ qemu-img info /export/vmimgs/snap2-testvm.qcow2
    image: /export/vmimgs/snap2-testvm.qcow2
    file format: qcow2
    virtual size: 20G (21474836480 bytes)
    disk size: 3.6M
    cluster_size: 65536
    backing file: /export/vmimgs/snap1-testvm.qcow2
    #--------------------------------------------#
    $ qemu-img info /export/vmimgs/snap1-testvm.qcow2
    image: /export/vmimgs/snap1-testvm.qcow2
    file format: qcow2
    virtual size: 20G (21474836480 bytes)
    disk size: 2.5M
    cluster_size: 65536
    backing file: /export/vmimgs/testvm.qcow2
    $
    #--------------------------------------------#

    Now, if we do not need snap2 any more, and want to pull all the data from snap1 into snap3, making snap1 as snap3’s backing file, we can do a virsh blockpulloperation as below:

    $ virsh blockpull --domain testvm 
      --path /export/vmimgs/snap3-testvm.qcow2 
      --base /export/vmimgs/snap1-testvm.qcow2 
      --wait --verbose
    Block Pull: [100 %]
    Pull complete

    可以看到snap3的backup为snap1

    $ qemu-img info /export/vmimgs/snap3-testvm.qcow2
    image: /export/vmimgs/snap3-testvm.qcow2
    file format: qcow2
    virtual size: 20G (21474836480 bytes)
    disk size: 145M
    cluster_size: 65536
    backing file: /export/vmimgs/snap1-testvm.qcow2

    snapshot-list 仍显示snap2

    $ virsh snapshot-list testvm --tree
    snap1-testvm
      |
      +- snap2-testvm
          |
          +- snap3-testvm

    所以仍可以恢复为

    base <- snap123

    External disk-snapshots(live) using RAW as original image: 

    源disk image 不变为raw,而snapshot为qcow2

    internal snapshots会导致源disk image变成qcow2

  • 相关阅读:
    appium常见问题03_appium脚本报错selenium.common.exceptions.WebDriverException
    如何保存android app日志
    appium常见问题02_android内嵌H5页(webview)如何定位
    appium常见问题01_android筛选下拉框无法定位问题
    数字类型
    计算机基础
    HTML5学习笔记
    spring boot-hello world
    C#开发移动应用系列(4.调用系统应用,以及第三方应用(调用与被调用))
    C#开发移动应用系列(3.使用照相机扫描二维码+各种基础知识)
  • 原文地址:https://www.cnblogs.com/allcloud/p/5074407.html
Copyright © 2011-2022 走看看