#!/bin/bash
EXPORT_LIST=("MARAZZI" "DEMO4" "HXCOPY" "CCL")

OUTPUT='/hana_data/SCHEMA_BACKUP/HOURLY'
dateStr=`date '+%F_%H'`
echo "Date: $dateStr"


for schema in ${EXPORT_LIST[@]}
do
        echo "exporting $schema"
        if test -e $OUTPUT/$schema
        then
           echo 'schema dir exist'
        else
           echo 'schema dir does not exist, create it'
           mkdir $OUTPUT/$schema
        fi

        hdbsql -i 01 -u $schema -p EPM_user_2017 "EXPORT $schema.\"*\" AS BINARY INTO '$OUTPUT/$schema/$dateStr' WITH REPLACE"
        if [ $? != "0" ]; then
              echo "exporting fails"
            else
              echo "exporting success"
            fi
done

echo "export end"