
#!/bin/bash
while read line; do
mtable="$line"
/usr/sap/SID/HDB80/exe/hdbsql -U SIDexp "EXPORT $mtable AS BINARY into '/hanabackup/export_test/tables'"
RC=$?
if [ $RC -eq 0 ]
then
echo "\n $mtable export completed successfully $RC"
fi
if [ $RC -ne 0 ]
then
echo "\n $mtable export completed with error $RC"
fi
done < /hanabackup/export_test/table_list.txt
#!/bin/bash
print_help ()
{
cat << !
Usage --> Script will import (binary exported using HANA tools) selected require tables to specified schema.
Paramters
USER KEY - hdbuserstore key to connect DB
HANA SID - Datbase SID
MSOURCE - Source schema name
MTARGET - Target schema name
EXPORT_PATH - Exported file path
table_file - List of tables to import schema_name.table_name format in text file with path
Examples
$0 --hdbkey=<<hdbuserstore KEY>> --sourceschema=<<MSOURCE>>
--targetschema=<<MTARGET>> --exportpath=<<EXPORT_PATH>>
--hsid=<<Database SID>>
--tablefile=<<List of schema_name.table with path>>
!
}
for margu in "$@"
do
PARM=$(echo $margu | cut -f1 -d=)
VALUE=$(echo $margu | cut -f2 -d=)
case $PARM in
--hdbkey)
mhkey=`echo $VALUE | tr 'A-Z' 'a-z' ` ;;
--sourceschema)
msource=$VALUE ;;
--hsid)
mhsid=$VALUE ;;
--tablefile)
mtablefile=$VALUE ;;
--exportpath)
mexportpath=$VALUE ;;
--targetschema)
mtarget=$VALUE ;
;;
*)
echo "Invalid Argument $PARM" ;
print_help $0 ;
exit 2;;
esac
done
if [ -z "$mhsid" ];
then
echo "Please check syntax --hsid "
print_help $0 ;
exit;
fi
if [ -z "$mtablefile" ];
then
echo "Please check syntax --tablefile "
print_help $0 ;
exit;
fi
if [ -z "$mhkey" ];
then
echo "Please check syntax --hdbkey "
print_help $0 ;
exit;
fi
if [ -z "$msource" ];
then
echo "Please check syntax for --sourceschema "
print_help $0 ;
exit;
fi
if [ -z "$mtarget" ];
then
echo "Please check syntax for --targetschema "
print_help $0 ;
exit;
fi
if [ -z "$mexportpath" ];
then
echo "Please check syntax for --exportpath "
print_help $0 ;
exit;
fi
mlogfile="`date \"+%Y%m%d_%H_%M_%S\"`"
mlogfile="$mtarget"_"$mlogfile"_"$iPrefix.log"
printf "\n Import - log file /tmp/$mlogfile using /usr/sap/$mhsid/HDB80/exe/hdbsql " >> /tmp/$mlogfile
printf "\n IMPORT <table_name> from '"$mexportpath"' WITH REPLACE DATA ONLY RENAME SCHEMA $msource TO $mtarget THREADS 10 " >> /tmp/$mlogfile
printf "\n --------------------------------------------------------------------------------------------------------------------------" >> /tmp/$mlogfile
printf "\n " >> /tmp/$mlogfile
printf "\n " >> /tmp/$mlogfile
#exit;
while read line; do
mtable="$line"
/usr/sap/$mhsid/HDB80/exe/hdbsql -U $mhkey "IMPORT $mtable from '"$mexportpath"' WITH REPLACE DATA ONLY RENAME SCHEMA $msource TO $mtarget THREADS 10"
RC=$?
if [ $RC -eq 0 ]
then
printf "\n $mtable import completed successfully from $msource TO $mtarget with error code $RC" >> /tmp/$mlogfile
fi
if [ $RC -ne 0 ]
then
printf "\n $mtable import from $msource TO $mtarget completed with error $RC" >> /tmp/$mlogfile
fi
done < $mtablefile
printf "\n eof " >> /tmp/$mlogfile
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
7 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 | |
4 |