代码拉取完成,页面将自动刷新
#!/bin/bash
Echo()
{
case $1 in
success) flag="\033[1;32m"
;;
failure) flag="\033[1;31m"
;;
warning) flag="\033[1;33m"
;;
msg) flag="\033[1;34m"
;;
*) flag="\033[1;34m"
;;
esac
if [[ $LANG =~ [Uu][Tt][Ff] ]]
then
echo -e "${flag}${2}\033[0m"
else
echo -e "${flag}${2}\033[0m" | iconv -f utf-8 -t gbk
fi
}
if [ ! $1 ];then
Echo "msg" "缺少必要参数"
Echo "msg" "创建快照请使用Create,如sh $(basename $0) Create"
Echo "msg" "恢复快照请使用Restore,如sh $(basename $0) Restore"
Echo "msg" "删除快照请使用Delete,如sh $(basename $0) Delete"
exit
else
flag=$1
fi
#创建快照
Create_snapshot()
{
virsh list --all
read -p "please input ebs_name:" ebs_name
read -p "please input snapsho_name:" snapsho_name
virsh snapshot-create-as $ebs_name $snapsho_name
virsh snapshot-current $ebs_name|grep name
virsh snapshot-list $ebs_name
qemu-img info /vmdata/${ebs_name}/${ebs_name}_os.qcow2
qemu-img info /vmdata/${ebs_name}/${ebs_name}_data.qcow2
}
#恢复快照
Restore_snapshot()
{
virsh list --all
read -p "please input ebs_name:" ebs_name
virsh snapshot-list $ebs_name
read -p "please input snapsho_name:" snapsho_name
virsh snapshot-revert $ebs_name $snapsho_name
virsh snapshot-current $ebs_name|grep name
}
#删除快照
Delete_snapshot()
{
virsh list --all
read -p "please input ebs_name:" ebs_name
virsh snapshot-list $ebs_name
read -p "please input snapsho_name:" snapsho_name
virsh snapshot-delete $ebs_name $snapsho_name
virsh snapshot-list $ebs_name
}
Main()
{
[ "$flag" == "Create" ] && Create_snapshot
[ "$flag" == "Restore" ] && Restore_snapshot
[ "$flag" == "Delete" ] && Delete_snapshot
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。