backup_mysql.sh

Remplacement de password.txt par .my.cnf
This commit is contained in:
2020-12-14 14:04:42 +01:00
parent 7f8ba8d3c6
commit 385d175e02

View File

@@ -21,9 +21,12 @@
#####################################################################
#
#
BKP_USER="mysqlbackupuser" # Enter the username for backup
BKP_PASS="$(cat $HOME/.password.txt)" # Enter the password of the backup user
BKP_BASE_DIR=$(dirname "$0")
# Read l/p from .my.cnf
#BKP_USER="mysqlbackupuser" # Enter the username for backup
#BKP_PASS="$(cat $HOME/.password.txt)" # Enter the password of the backup user
#BKP_PASS="${PASSWORD}" # direnv (.envrc)
#
BKP_DEST="$HOME/Documents/MySQL" # Enter the Backup directory,change this if you have someother location
if [ ! -d $BKP_DEST ]; then mkdir $BKP_DEST; fi
@@ -89,7 +92,9 @@ notification() {
###################### Get database list ################################
#
DB_LIST="$($MYSQL -u $BKP_USER -h $MYSQL_HOST -p$BKP_PASS -Bse 'SHOW DATABASES')"
#DB_LIST="$($MYSQL -u $BKP_USER -h $MYSQL_HOST -p$BKP_PASS -Bse 'SHOW DATABASES')"
DB_LIST="$($MYSQL -h $MYSQL_HOST -Bse 'SHOW DATABASES')"
#
for db in $DB_LIST
do
@@ -108,7 +113,8 @@ do
#
################ Using MYSQLDUMP for bakup and Gzip for compression ###################
#
$MYSQLDUMP -u $BKP_USER -h $MYSQL_HOST -p$BKP_PASS -r$BKP_FILENAME $db
#$MYSQLDUMP -u $BKP_USER -h $MYSQL_HOST -p$BKP_PASS -r$BKP_FILENAME $db
$MYSQLDUMP -h $MYSQL_HOST -r$BKP_FILENAME $db
$GZIP -9 $BKP_FILENAME
server1="ftp.cluster011.ovh.net:backup/SilverBook/Bases_MySQL/"