#!/bin/bash
EXPORT_LIST=("DEMO3" "YOUGU" "CENSH" "DEMO4" "CCL" "SECAWORLD" "EPM3" "CHK" "YATAL")

dateStr=`date '+%F'`
echo "Date: $dateStr"
mkdir /hana_data/SCHEMA_BACKUP/$dateStr
chmod -R a+w /hana_data/SCHEMA_BACKUP/$dateStr

for schema in ${EXPORT_LIST[@]}
do
        echo "exporting $schema"
        hdbsql -i 01 -u $schema -p EPM_user_2017 "EXPORT $schema.\"*\" AS BINARY INTO '/hana_data/SCHEMA_BACKUP/$dateStr/$schema' WITH REPLACE"
        if [ $? != "0" ]; then
      echo "exporting fails"
    else
      echo "exporting success"
    fi
done

#echo "exporting PINGAN"
#/usr/sap/hdbclient/hdbsql -i 00 -u PINGAN -p EPM_user_2022 "EXPORT PINGAN.\"*\" AS BINARY INTO '/hana/mounts/SCHEMA_BACKUP/$dateStr/PINGAN' WITH REPLACE"

echo "export end"