#!/bin/csh

echo "## `/bin/date +%FT%T`"

set EMAILTO = ps-ipp-ops@ifa.hawaii.edu

################################## ippRequestServer ##############################################
# dump ippRequestServer from ippc19
set DUMP_PATH = /data/ipp001.0/ipp/mysql-dumps       #path(SAB)
mysqldump --compress -hippc19 -uipp -pipp --flush-logs --single-transaction --log-error=RS-err ippRequestServer | bzip2 > $DUMP_PATH/mysql-RS-ippc19-`date +%FT%T`.dump.bz
if ($status != 0) then
   /bin/mail -s "Warning ippRequestServer/RS dump failed" $EMAILTO < msg
endif

################################## ippadmin ##############################################
# dump ippadmin from ippdb01
set DUMP_PATH = /data/ipp001.0/ipp/mysql-dumps               #path(SAB)
set DATEVAR=`date +%FT%T`                                    #date
set FILENAME = $DUMP_PATH/mysql-ippadmin-ipp001-$DATEVAR.dump.bz
mysqldump --compress -hipp001 -uipp -pipp --single-transaction ippadmin | bzip2 > $FILENAME
if ($status != 0) then
   /bin/mail -s "Warning ippadmin dump failed" $EMAILTO < msg  
endif

# simlink to ippadmin ippdb01 dump
set DUMP_PATH = /data/ipp001.0/ipp/mysql-dumps       #path(SAB)
cd $DUMP_PATH/distribution/                          #link dir
ln -f  ../mysql-ippadmin-ipp001-$DATEVAR.dump.bz ippdb01-ippadmin.dump.bz

################################## isp ##############################################
# dump isp from ippdb01
set DUMP_PATH = /data/ipp001.0/ipp/mysql-dumps               #path(SAB)
set DATEVAR=`date +%FT%T`                                    #date
set FILENAME = $DUMP_PATH/mysql-isp-ipp001-$DATEVAR.dump.bz
mysqldump --compress -hippdb01 -uipp -pipp --flush-logs --single-transaction isp | bzip2 > $FILENAME
if ($status != 0) then
   /bin/mail -s "Warning isp dump failed" $EMAILTO < msg  
endif

################################## ssp ##############################################
# dump ssp from ippdb01
set DUMP_PATH = /data/ipp001.0/ipp/mysql-dumps               #path(SAB)
set DATEVAR=`date +%FT%T`                                    #date
set FILENAME = $DUMP_PATH/mysql-ssp-ipp001-$DATEVAR.dump.bz
mysqldump --compress -hippdb01 -uipp -pipp --flush-logs --single-transaction ssp | bzip2 > $FILENAME
if ($status != 0) then
   /bin/mail -s "Warning ssp dump failed" $EMAILTO < msg
endif

# simlink to isp ippdb01 dump
set DUMP_PATH = /data/ipp001.0/ipp/mysql-dumps       #path(SAB)
cd $DUMP_PATH/distribution/                          #link dir
ln -f  ../mysql-isp-ipp001-$DATEVAR.dump.bz ippdb01-isp.dump.bz

