zoukankan      html  css  js  c++  java
  • vsphere vdp备份情况导出

    今天在处理vdp遗留问题,有些机器下线了还在备份,有些机器改名了已经备份不了等等问题,想要将vdp里面的备份任务以及任务情况导出来,终于找到了mccli这个软件,能将vdp的相关信息查找出来

    具体参考:

    mccli使用文档:

    Dell EMC Avamar Management Console Command Line Interface (MCCLI) Guide (delltechnologies.com)

    有大佬写了脚本:

    shellscripts/backup-job-detail.sh at master · happycow92/shellscripts · GitHub

    不过内容不是我想要的,于是改了一些,拿到自己想要的信息

    #!/bin/bash
    source /etc/profile
    clear
    printf 'job_name			vm_name						status				error_code	last_start_time		last_end_time		Elapsed		bytes		retention	date		
    '
    IFS=$'
    '
    vcenter_name=$(cat /usr/local/vdr/etc/vcenterinfo.cfg | grep vcenter-hostname | cut -d '=' -f 2)
    job_name=$(mccli group show --recursive=true | grep -i "/$vcenter_name/VirtualMachines" | awk -F/. '{print $(NF-2)}')
    date=$(date "+%F" -d "-1days")
    
    for i in $job_name
    do
        info=""
        stat=""
        start_time=""
        end_time=""
        elapsed=""
        er_code=""
        retention=""
        bytes=""
    
        clients=$(mccli group show-members --name=/$vcenter_name/VirtualMachines/$i | grep -Po '.*/K.*' | awk 'NF{NF-=2};1')
        retention=$(mccli retention show --name=/$vcenter_name/VirtualMachines/$i|grep Basic|awk '{print $(NF-1)"_"$NF}')
        
        for client_name in $clients
        do 
     
            if [ ! -z "$client_name" ];then
                info=$(mccli activity show --completed=true --name=/$vcenter_name/VirtualMachines/$client_name|grep -v '^$'|tail -n +4|sort -rk 1|head -n 1)
    
                if [ -z "$info" ];then
                    printf "%-31s %-47s %-31s %-15s %-23s %-23s %-15s %-15s %-15s
    " "$i" "$client_name" "$stat" "$er_code" "$start_time" "$end_time" "$elapsed" "$bytes" "$retention"
                    continue
                fi
    
            stat=$(echo $info|awk -F'%' '{print $1}'|awk '{for (i=2;i<=(NF-13);i++)  print $i}'|paste -d "_" -s)
            start_time=$(echo $info|awk -F'%' '{print $1}'|awk '{print $(NF-11)"_"$(NF-10)}')
            elapsed=$(echo $info|awk -F'%' '{print $1}'|awk '{print $(NF-8)}')
            end_time=$(echo $info|awk -F'%' '{print $1}'|awk '{print $(NF-7)"_"$(NF-6)}')
            er_code=$(echo $info|awk -F'%' '{print $1}'|awk '{print $(NF-12)}')
            bytes=$(echo $info|awk -F'%' '{print $1}'|awk '{print $(NF-2)"_"$(NF-1)}')
                
            fi
                
            printf "%-31s %-47s %-31s %-15s %-23s %-23s %-15s %-15s %-15s %-15s
    " "$i" "$client_name" "$stat" "$er_code" "$start_time" "$end_time" "$elapsed" "$bytes" "$retention" "$date"
            
        done
    done

    输出内容如下:

    job_name为vdp备份的任务名,vm_name为实际备份的虚拟机名,status为最近一次备份的状态,error_code为错误代码,last_time为最近一次备份完成的时间,retention为备份保留的天数

  • 相关阅读:
    [转]Java中的POJO类
    使用PD进行数据库建模时的问题
    N-Gram模型
    [转] C#开源项目大全
    HTTP Error 503. The service is unavailable.
    abp 取消权限校验
    Oracle expdp/impdp导出导入命令及数据库备份(转)
    Oracle ORA-14102: 只能指定一个 LOGGING 或 NOLOGGING 子句
    Oracle ORA-01940: 无法删除当前连接的用户
    Oracle 把查询的多个字段赋值给多个变量
  • 原文地址:https://www.cnblogs.com/old-path-white-cloud/p/14705961.html
Copyright © 2011-2022 走看看