Get Adobe Flash player

Mysql Backup Skript Linux

Mysql Backup Skript für Linux

z.B. für Xampp Datenbank

 

#!/bin/sh
if test „$1“ != „“
then
passwd=“-p$1″
else
passwd=““
fi

d=`echo „show databases“ | /opt/lampp/bin/mysql -uroot $passwd 2>/dev/null`
if test -z „$d“
then
echo „Can’t access database. Is MySQL running? Added the MySQL root password to end of command line?“
exit
fi

echo „Backing up databases…“
for i in $d
do
if test „$i“ = „Database“
then
continue
fi
/opt/lampp/bin/mysqldump -a -Q -B -e –add-drop-table -uroot $passwd $i > $i.sql 2> output
if test $? -eq 0
then
:
else
echo „$i: FAILED“
exit
fi
done

tar czfv backup.tgz  /home/service/daten/ ./*.sql

cp backup.tgz lampp_backup.$(date „+%y%m%d“).tgz
rm *.sql
rm backup.tgz