#!/bin/bash
CUR_DIR=$(cd $(dirname $0);pwd)
BACKUP_TO=$CUR_DIR/epgrec-backup
MYSQL_PW=`cat ~/.mysql-pw-epgrec`

if [ ! -d "$BACKUP_TO" ]; then
    mkdir -p "$BACKUP_TO"
fi
cd $BACKUP_TO

# backup
cp -f /var/www/epgrec/config.php .
cp -f /var/www/epgrec/do-record.sh .
cp -rf /var/www/epgrec/thumbs .
cp -rf /var/www/epgrec/video .
mysqldump -u epgrec -p$MYSQL_PW --single-transaction epgrec | gzip > mysql.epgrec.`date +%Y%m%d`.gz

# restore
#cat mysql.epgrec.YYYYMMDD.gz | gunzip | mysql -u epgrec -p$MYSQL_PW epgrec

cd $CUR_DIR
