Last active
January 31, 2024 06:57
-
-
Save joker-x/10944024 to your computer and use it in GitHub Desktop.
Vuelca todas las bases de datos separadas y comprimidas con gzip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Requiere tener configurado el acceso a MySQL en ~/.my.cnf | |
if [ ! -f ~/.my.cnf ]; then | |
echo "ERROR: No existe ~/.my.cnf" | |
exit 1 | |
fi | |
# Para usar junto con rsnapshot los ficheros generados deben | |
# estar en el directorio actual. Por ello el valor de DESTINO | |
# por defecto es . | |
DESTINO=. | |
if [ $# -eq 1 ]; then | |
DESTINO="$1" | |
fi | |
if [ $# -gt 1 ]; then | |
echo "ERROR: Número de argumentos incorrecto." | |
exit 1 | |
fi | |
if [ ! -d $DESTINO ]; then | |
echo "ERROR: ${DESTINO} no es un directorio" | |
exit 1 | |
fi | |
BBDD=$(mysql --skip-column-names --silent -e 'SHOW DATABASES;') | |
for BD in $BBDD | |
do | |
#echo "Exportando $BD" | |
ionice -c2 -n7 nice -n19 mysqldump --single-transaction ${BD} | gzip -c -9 > ${DESTINO}/${BD}.gz | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wonderful! ...Thank you very much!
:-)