#!/bin/sh

. ./config.sh

BACKUP_DIR=/a/backup/svn/work

echo Zaloha databaze...

function backup_db
{
DB_NAME=$1
echo -ne "${DB_NAME}: "
cd ${BACKUP_DIR}/${DB_NAME}
for I in $(mysql -N -B -u ${DB_USER} --password=${DB_PASSWORD} -e "show tables from \`${DB_NAME}\`" -s --skip-column-names);
do
  echo -ne "$I, "
  mysqldump -u ${DB_USER} --password=${DB_PASSWORD} ${DB_NAME} $I --skip-dump-date --extended-insert=FALSE> "$I.sql";
done
svn add * -q
echo ""
}

backup_db forum
backup_db is
backup_db sunrisechat
backup_db www
backup_db share
backup_db wiki

# Commit working copy
cd ${BACKUP_DIR}
svn commit -m "" .
svn cleanup

cd "$( dirname "${BASH_SOURCE[0]}" )"

echo Hotovo
