#!/bin/bash
#
# Database backup script
#
# Filename: db_backup.sh
#
# Copyright Ben Tasker 2009
# Released under the GNU GPL.
# See http://benscomputer.no-ip.org/LICENSE for a copy of the license



source /etc/db_claims.sh

if [ "$PROGROOT" == "" ]
then
# Config Variables not set
echo "BADREQUEST"
exit

fi

if [ "$BACKUPDIR" == "" ]
then
# Config Variables not set
echo "BADREQUEST"
exit

fi

DATESTAMP=$( date +'%H-%d-%m-%Y.tar' )


cd /tmp
tar -cf "$DATESTAMP" "$PROGROOT" 2> /dev/null > /dev/null
if [ "$?" == "1" ]
then
echo "FAILED"
exit
fi

gzip "$DATESTAMP" 2> /dev/null > /dev/null
if [ "$?" == "1" ]
then
echo "FAILED"
exit
fi

mv "$DATESTAMP" "$BACKUPDIR"
if [ "$?" == "1" ]
then
echo "FAILED"
exit
fi
echo "SUCCESS"
exit
