All,
I am a newbie to scripting and would appreciate any assistance on the following. I am a NetBackup administrator and just completed a disaster recovery exercise. Thankfully this was only six clients to recover. While working on the exercise I decided to try and script everything and found a way to get what I needed but some parts I am certain could be scripted more efficiently.
What I am doing in this example is to obtain all of the available backups between the date range specified from each client one at a time. Is there a way to pass along two ( or more ) variables to a single line for all of the clients instead of running the command for each client individually?
I want to take this and shrink it down to a single line that somehow reads a file of the clients that I created call /tmp/clients.lst and it would loop thru the file to find the client name and the dates for each one and continue until it loops through for each clients and its dates.
sudo /usr/openv/netbackup/bin/admincmd/bpimagelist -U -client 123 -d 02/10/2013 -e 03/04/2013 | awk '{print $1}' | sed '1,2d' >> /tmp/dates.tmp
sudo /usr/openv/netbackup/bin/admincmd/bpimagelist -U -client 456 -d 02/10/2013 -e 03/04/2013 | awk '{print $1}' | sed '1,2d' >> /tmp/dates.tmp
sudo /usr/openv/netbackup/bin/admincmd/bpimagelist -U -client 789 -d 02/10/2013 -e 03/04/2013 | awk '{print $1}' | sed '1,2d' >> /tmp/dates.tmp
sudo /usr/openv/netbackup/bin/admincmd/bpimagelist -U -client 123 -d 02/10/2013 -e 03/04/2013 | awk '{print $1}' | sed '1,2d' >> /tmp/dates.tmp
sudo /usr/openv/netbackup/bin/admincmd/bpimagelist -U -client 456 -d 02/10/2013 -e 03/04/2013 | awk '{print $1}' | sed '1,2d' >> /tmp/dates.tmp
sudo /usr/openv/netbackup/bin/admincmd/bpimagelist -U -client 789 -d 02/10/2013 -e 03/04/2013 | awk '{print $1}' | sed '1,2d' >> /tmp/dates.tmp
Here is how I got it to work running each client by itself...
=> vi /tmp/alldates
sudo /usr/openv/netbackup/bin/admincmd/bpimagelist -U -client 123 -d 02/10/2013 -e 03/04/2013 | awk '{print $1}' | sed '1,2d' >> /tmp/dates.tmp
sudo /usr/openv/netbackup/bin/admincmd/bpimagelist -U -client 456 -d 02/10/2013 -e 03/04/2013 | awk '{print $1}' | sed '1,2d' >> /tmp/dates.tmp
sudo /usr/openv/netbackup/bin/admincmd/bpimagelist -U -client 789 -d 02/10/2013 -e 03/04/2013 | awk '{print $1}' | sed '1,2d' >> /tmp/dates.tmp
sudo /usr/openv/netbackup/bin/admincmd/bpimagelist -U -client 123 -d 02/10/2013 -e 03/04/2013 | awk '{print $1}' | sed '1,2d' >> /tmp/dates.tmp
sudo /usr/openv/netbackup/bin/admincmd/bpimagelist -U -client 456 -d 02/10/2013 -e 03/04/2013 | awk '{print $1}' | sed '1,2d' >> /tmp/dates.tmp
sudo /usr/openv/netbackup/bin/admincmd/bpimagelist -U -client 789 -d 02/10/2013 -e 03/04/2013 | awk '{print $1}' | sed '1,2d' >> /tmp/dates.tmp
=> chmod 777 /tmp/alldates
=> /tmp/alldates
=> cat /tmp/dates.tmp | sort -u > /tmp/dates.lst
=> cat /tmp/dates.lst
02/10/2013
02/11/2013
02/12/2013
02/13/2013
Thank you...