PVE AutoSnap 工具使用
文章目录
项目介绍
安装和使用
|
|
使用
-
备份快照
1 2 3 4 5 6 7 8 9 10 11
SNAP_LIST="111,101" PVE_USER='root@pam' PVE_PASSWD='xxx' PVE_HOST='192.168.8.19' for vmid in ${SNAP_LIST//,/ };do cv4pve-autosnap --host=${PVE_HOST} \ --username=${PVE_USER} \ --password=${PVE_PASSWD} --vmid=${vmid} \ snap --label=daily --keep=3 done
-
查看快照
1 2 3 4 5 6 7 8 9
SNAP_LIST="111,101" PVE_USER='root@pam' PVE_PASSWD='xxx' PVE_HOST='192.168.8.19' cv4pve-autosnap --host=${PVE_HOST} \ --username=${PVE_USER} \ --password=${PVE_PASSWD} \ --vmid=111 status
与 Gitlab 集成
-
Script.pve-snap 文件如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
# Script.pve-snap 文件如下 #!/bin/bash #Filename: Script.pve-snap #Revision: v1 #Date: 2023/9/25 #Author: yangzun #Email: yangzun@treesir.pub #Description: PVE VM SNAPSHOT SNAP_LIST=${SNAP_LIST-'101'} PVE_USER=${PVE_USER-'root@pam'} PVE_PASSWD=${PVE_PASSWD-'12345'} PVE_HOST=${PVE_HOST-'192.168.8.19'} function install_autosnap(){ wget https://github.com/Corsinvest/cv4pve-autosnap/releases/download/v1.14.8/cv4pve-autosnap-linux-x64.zip unzip cv4pve-autosnap-linux-x64.zip mv cv4pve-autosnap /usr/bin/ chmod a+x /usr/bin/cv4pve-autosnap } if [ "${1}" == 'exec' ];then install_autosnap for vmid in ${SNAP_LIST//,/ };do cv4pve-autosnap --host=${PVE_HOST} \ --username=${PVE_USER} \ --password=${PVE_PASSWD} --vmid=${vmid} \ snap --label=daily --keep=3 done elif [ "${1}" == 'plan' ];then install_autosnap for vmid in ${SNAP_LIST//,/ };do cv4pve-autosnap --host=${PVE_HOST} \ --username=${PVE_USER} \ --password=${PVE_PASSWD} --vmid=${vmid} \ status done fi
-
CI 文件如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
variables: extends: .default_vars # Run test job always .plan: stage: plan extends: - .schedule_trigger_disble # Run build job only on a default branch when triggered manually .exec: stage: exec extends: - .master_schedule_manual_trigger .extends_group: extends: - .runner_tag - .harbor_auth_vars - .load_function_before_jobs - .script_exec_vars - .nexus_auth_vars .plan_script: &plan_script extends: - .plan - .extends_group script: - set -- $CI_JOB_NAME - chmod a+x Script.$1 - ./Script.$1 plan .exec_script: &exec_script extends: - .exec - .extends_group script: - set -- $CI_JOB_NAME - chmod a+x Script.$1 - ./"Script.$1" exec # 预运行脚步 pve-snap plan: *plan_script # 执行脚步 pve-snap exec: *exec_script