#!/bin/bash
MyUSER="backup"
MyPASS="backup"
MyHOST="localhost"
MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"
SMOOSH="$(which tar) cjf"
DEST="/u01/backups/"$(date +%Y%m%d)
[ ! -d $DEST ] && mkdir -p $DEST
cd $DEST
# MySQL DB Backup
FILE="$DEST/db.sql.gz"
$MYSQLDUMP -u $MyUSER -p$MyPASS --ignore-table=db.ADDROBJ --ignore-table=db.HOUSE --quick db | gzip > $FILE
# File Backups
BACKUPS=(/opt/www/hprojectserver/* )
FILE="$DEST/files.bz2"
$SMOOSH $FILE ${BACKUPS[@]}
#Clear older backupds
find /u01/backups/ -mtime +30 -type d -exec rm -rf {} \;