#script que guarda copia de todas la bases de datos
#!/bin/bash
## BEGIN CONFIG
##
FECHA=`date +%Y%m%d%H%M%S`HOST=localhost
USER=root
PASS=secretodeusuario
BACKUP_DIR=/root/backups
## END CONFIG ##
if [ ! -d $BACKUP_DIR ];
then
mkdir -p $BACKUP_DIR
fi
# Backup de MySQL
MYSQL_DBS=$(mysqlshow -h $HOST -u $USER -p$PASS | awk ' (NR > 2) && (/[a-zA-Z0-9]+[ ]+[|]/) && ( $0 !~ /mysql/) { print $2 }');
for DB in $MYSQL_DBS ;
do
echo "* Backuping MySQL data from $DB@$HOST..."
mysqldump -h $HOST -u $USER -p$PASS $DB > $BACKUP_DIR/$FECHA.mysql_$DB.sql
done
ls -l $BACKUP_DIR
No hay comentarios:
Publicar un comentario