KVM虚拟机做快照 备份虚拟机脚本

#!/bin/bash
DATE=$(date +%Y%m%d)
DATE2=’date -d “1 week ago” +%Y%m%d’
cd /data/vmdisk
virsh snapshot-create-as –domain AD-200-232 –name snap-AD-200-232-$DATE >> snapshot.log
virsh snapshot-delete –domain AD-200-232 –snapshotname snap-AD-200-232-$DATE2 >> snapshot.log
virsh dumpxml AD-200-232 > AD-200-232.xml
scp AD-200-232.img 192.168.202.30:/data/vmbak/AD-200-232-$DATE.img
scp AD-200-232.xml 192.168.202.30:/data/vmdbk/AD-200-232-$DATE.xml

 

virsh snapshot-create-as   建快照命令

virsh snapshot-delete  删除快照命令

virsh dumpxml 导出虚拟机配置文件

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *