cancel
Showing results for 
Search instead for 
Did you mean: 

Loop script to expire images using bpexpdate

Johncu
Level 3

Hi

I am not great at scripting, and I have a few images I would like to manually expire.

I have copied them all into an input file and atempted to write a simple loop script as follows:
 

for x in `cat /opt/openv/netbackup/scripts/input`

do sed "/opt/openv/netbackup/bin/admincmd/bpexpdate -recalculate -backupid $y -d 0"
done

however it is not working returning 'Unrecognized command'

does anyone have a script I could use to manual expire all my images, I don't want to have to type in the bpexpdate comand for each and every one.

Many thanks

1 ACCEPTED SOLUTION

Accepted Solutions

rjrumfelt
Level 6
with a list of images you need changed, name it  whatever


for i in `cat image_list`
do
echo $i
<install_path>/openv/netbackup/bin/admincmd/bpexpdate -backupid $i -d 0
done


not sure why you are using sed


***EDIT***
Make sure you are running your script as root, if not, make sure you add sudo to the command in the script

View solution in original post

3 REPLIES 3

rjrumfelt
Level 6
with a list of images you need changed, name it  whatever


for i in `cat image_list`
do
echo $i
<install_path>/openv/netbackup/bin/admincmd/bpexpdate -backupid $i -d 0
done


not sure why you are using sed


***EDIT***
Make sure you are running your script as root, if not, make sure you add sudo to the command in the script

J_H_Is_gone
Level 6


for x in $(</opt/openv/netbackup/scripts/input)
do
echo "working on image $x"
/opt/openv/netbackup/bin/admincmd/bpexpdate -recalculate -backupid $x -d 0
done

 

the for loop will read in the contents of the file input one line at a time
it will then put that item where ever $x appears
it will then loop until there are no more line items in the file input.

Johncu
Level 3

both working great, many thanks!