#!/bin/bash

datum=`date +%F`
dbyd=`date +%F --date="-48hour"`


set -C


path=/home/operator/budb
logfile=$path/log/budb$datum.log

date > $logfile

#echo $logfile

echo "today: $datum" >> $logfile 2>&1
echo "dbyesterday: $dbyd" >> $logfile 2>&1

file=$path/alldatabases
end=.sql.bz2

dbydfile=$file$dbyd$end
echo "removing old file..." >> $logfile 2>&1

rm -v $dbydfile >> $logfile 2>&1

echo "writing all databases to file..." >> $logfile 2>&1
set +C
mysqldump --host=hercules --all-databases -u dump | bzip2 -9 -c > $file$datum$end 2>> $logfile


