公司通过tsm备份数据,就写了个脚本菜单。
#/bin/sh
backname=''
function menu {
clear
echo
echo "\t1. restore backup file to local"
echo "\t2. restore log file to local"
echo "\t3. rename backup file name"
echo "\t0. exit"
echo --------------------------
echo --------------------------
read option
}
while [ 1 ]
do
menu
case $option in
0)
break;;
1)
cd /home/db2inst2/cutelink
dsmc q backup /AODB/NODE0000/ -password=yourpass |grep FULL* |awk '{print $8;}' > temp.txt
echo "\n"
grep -n FULL* temp.txt
echo "\nplease input your selected[3]:"
read op
case $op in
1)
backname=`sed -n '1p' temp.txt`;;
2)
backname=`sed -n '2p' temp.txt`;;
*)
backname=`sed -n '3p' temp.txt`;;
esac
cd /usr/backup
rm /usr/backup/*
echo $backname
dsmc restore $backname /usr/backup/ -password=yourpass;;
2)
cd /home/db2inst2/cutelink
echo "please input start date 3 days ago"
echo "date format (m/d/y) (example:02/20/2013):"
read daytime
dsmc q arch -fromdate=$daytime /home/db2inst1/arch/db2inst1/AODB/NODE0000/C0000003/ -password=DBServer |grep home|awk '{print $3,$5;}' >temp.txt
echo "\n"
grep -n home temp.txt
echo "\nplease input your select [1,2,...]"
echo "\n(please select *.log file that date same as FULL_BACKUP.* file): "
read op
logname=`eval sed -n '${op}p' temp.txt|awk '{print $2;}'`
dsmc retrieve $logname /usr/backup/ -password=youpass;;
3)
cd /usr/backup
chmod 777 *
datename=`ls FULL*|cut -d . -f2`
if [ -f FULL* ]
then
mv FULL* AODB.0.db2inst1.NODE0000.CATN0000.${datename}.001
echo "rename sucessful,press any key to continue"
else
echo "please downland backup file at first,do step 1"
fi
read dd;;
*)
clear
echo "sorry,wrong selection";;
esac
done