MySQL-Backup-Script
Posted: 2003-03-04 09:08
Huhu hab da ein kleines problemchen :-)
Also folgendes hab ich so teilweise im netz gefunden
Anfangs ging es garnicht nun nicht vollständig
Databases und tabellen die ich noch in der Variable not_dump_db angebe werden nicht herausgefiltert :-/
mit egrep -v gings auch nicht :-(
Also folgendes hab ich so teilweise im netz gefunden
Anfangs ging es garnicht nun nicht vollständig
Code: Select all
#!/bin/sh
mysql_host="localhost"
mysql_rootpasswd="glaubstduecht?"
backupdir="/var/backup"
mysql_backupdir="${backupdir}/mysqldump"
mysql_dump="/usr/bin/mysqldump"
mysql_show="/usr/bin/mysqlshow"
## 1 = yes(xxxx-2001xxxx-xx.sql.gz)
## 0 = no
db_compress="1"
## not include list
not_dump_db=""
sysdtime=`date +%Y%m%d-%H`
mysql_connect="-h $mysql_host -u root -p$mysql_rootpasswd"
mysql_DBs="`$mysql_show $mysql_connect | grep -v '(${not_dump_db}|Databases|+)' | awk '{print $2}' 2>/dev/null`"
mysql_dump_work() {
mysql_each_DB="$1"
mysql_dump_file="${mysql_backupdir}/${mysql_each_DB}-${sysdtime}.sql"
$mysql_dump $mysql_connect $mysql_each_DB > $mysql_dump_file
if [ "$db_compress" = "1" ] ; then
gzip -9 $mysql_dump_file
fi
}
if [ "$mysql_DBs" != "" ] ; then
if [ ! -d "$mysql_backupdir" ] ; then
mkdir -p "$mysql_backupdir"
chmod 700 "$mysql_backupdir"
fi
for mysql_DB in $mysql_DBs ; do
mysql_dump_work $mysql_DB
done
fi
exit 0
mit egrep -v gings auch nicht :-(