#!/bin/bash
#
# backupExecuter
# --------
# Utility shell script to perform an online backup


USER=cgadm/cgadm
HOST=cora
PORT=2000
CGADM="/usr/local/bin/cgadm --server=$HOST --port=$PORT --user=$USER"
MSG="'Backup by backupExecuter'"

### end of customizing ####

TS=$1
if [ -z "$TS" ]
then
    echo "No tableset defined"
    exit 1
fi 

echo "Starting backup .."

$CGADM --cmd="begin backup for ${TS} message ${MSG};"
if [ $? -ne 0 ]
then
    echo "Start Backup failed"
    exit 1
fi 

$CGADM --cmd="backup tableset ${TS};"
if [ $? -ne 0 ]
then
    echo "Backup failed"
    exit 1
fi 


echo "Ending backup .."
$CGADM --cmd="end backup for ${TS};"
if [ $? -ne 0 ]
then
    echo "End Backup failed"
    exit 1
fi 

echo "Backup completed."
exit 0

