This script allows you to mass cancel active backup jobs from command line of vSphere Data Protection Appliance.
A much more interactive script to cancel "Active" "Waiting-Queued" and "Waiting-Client" jobs.
#!/bin/bash # This script cancels all active backup jobs from the command line value=$(mccli activity show --active | cut -c1-16 | sed -e '1,3d') if [ -z "$value" ] then echo "No active job to cancel" else for p in $value do mccli activity cancel --id=$p done fi
If you would like to cancel a set of backup jobs, like 13 jobs out of 20 running jobs, then you need to add those Job ID's to a file and then run the script to pull inputs from that file
#!/bin/bash
# This script cancels jobs from IDs provided in the id.txt file
while read p; do
mccli activity cancel --id=$p
done <id.txt
This script can be modified for other backup states like waiting-client. Just Grep, and cut, and remove the first three rows and feed the job ID's to a loop.
A much more interactive script to cancel "Active" "Waiting-Queued" and "Waiting-Client" jobs.
#!/bin/bash
# This block is for help parameters.
usage()
{
cat << EOF
Below are the available fields
OPTIONS:
-h Help
-a Active Job
-w Waiting Job
EOF
}
# This block saves status of active/waiting-client/waiting-queued backups
value=$(mccli activity show --active | cut -d ' ' -f 1 | sed -e '1,3d')
value_client=$(mccli activity show | grep -i "Waiting-Client" | cut -d ' ' -f 1)
value_queued=$(mccli activity show | grep -i "Waiting-Queued" | cut -d ' ' -f 1)
# This block does a flag input
while getopts "haw" option
do
case $option in
a)
if [ -z $value ]
then
printf "No active jobs to cancel\n"
else
printf "Cancelling active jobs\n"
for i in $value
do
mccli activity cancel --id=$i
done
fi
;;
w)
if [ -z $value_client ]
then
echo $value_client
printf "No jobs in waiting client state\n"
else
printf "Cancelling waiting clients\n"
for i in $value_client
do
mccli activity cancel --id=$i
done
fi
if [ -z $value_queued ]
then
printf "No jobs in waiting queued state\n"
else
printf "Cancelling queued clients\n"
for i in $value_queued
do
mccli activity cancel --id=$i
done
fi
;;
h)
usage
;;
?)
printf "type -h for list\n"
;;
esac
done
Chmod a+x to the file for execute. Hope this helps!
0 comments:
Post a Comment