Autor: @NerdChileno
Descripción: Crea backups comprimidos para cada una de las bases de datos en el motor.
#!/bin/sh
#
# syslock.cl
# Copyright GPL V.3
# 06/03/2010
# Version: 1.0.10
#
# ---------------------------------------------------------------------
#
NOW="$(date +"%Y%m%d")"
MyUSER="" #USUARIO
MyPASS="" # PASSWORD
MyHOST="localhost" # HOST
MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"
CHOWN="$(which chown)"
CHMOD="$(which chmod)"
GZIP="$(which gzip)"
DEST="/home/mysqldump/unaxuna" #DIR DE DESTINO
MBD="$DEST/$NOW"
HOST="$(hostname)"
FILE=""
DBS=""
OMITE="test" # OMITIR BASE PARA RESPALDO
[ ! -d $MBD ] && mkdir -p $MBD || :
$CHOWN 0.0 -R $DEST
$CHMOD 0600 $DEST
DBS="$($MYSQL -u $MyUSER -h $MyHOST -p$MyPASS -Bse 'show databases')"
for db in $DBS
do
skipdb=-1
if [ "$OMITE" != "" ];
then
for i in $OMITE
do
[ "$db" == "$i" ] && skipdb=1 || :
done
fi
if [ "$skipdb" == "-1" ] ; then
FILE="$MBD/$NOW.$db.gz"
$MYSQLDUMP -u $MyUSER -h $MyHOST -p$MyPASS $db | $GZIP -9 > $FILE
fi
done
0 comentarios:
Publicar un comentario