SB
arcdir=$1
bindir=/usr/bin
PASS=New111
USAGE= "Usage: arcdb hourly|daily|mountly [SQLhost]"
if [ "$4" = "" ]; then
SQLhost='127.0.0.1'
fi
echo "SQLhost: $SQLhost"
if ! [ -d $1 ]; then
echo $USAGE
exit 1
fi
echo "Target dir: $1"
if [ "$3" = "" ]; then
echo $USAGE
exit 1
fi
echo "Database: $3"
case $2 in
hourly)
find $arcdir/$2/$3/ -type f -ctime 1 -delete
;;
daily)
find $arcdir/$2/$3/ -type f -ctime 31 -delete
;;
monthly)
find $arcdir/$2/$3/ -type f -ctime 365 -delete
;;
*)
echo $USAGE
exit 1
;;
esac
if ! [ -e $arcdir/$2/$3 ]; then
mkdir $arcdir/$2/$3
fi
export PGPASSWORD=New111
$bindir/pg_dump -h $SQLhost -U postgres -c $3 | gzip >>$arcdir/$2/$3/
date +%y%m%d%H%M
.gz