Forum Discussion

Johncu's avatar
Johncu
Level 3
16 years ago
Solved

Loop script to expire images using bpexpdate

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

  • 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

3 Replies

  • 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


  • 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.