backup_mysql.sh
Remplacement de password.txt par .my.cnf
This commit is contained in:
@@ -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")
|
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
|
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
|
if [ ! -d $BKP_DEST ]; then mkdir $BKP_DEST; fi
|
||||||
@@ -89,7 +92,9 @@ notification() {
|
|||||||
|
|
||||||
###################### Get database list ################################
|
###################### 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
|
for db in $DB_LIST
|
||||||
do
|
do
|
||||||
@@ -108,7 +113,8 @@ do
|
|||||||
#
|
#
|
||||||
################ Using MYSQLDUMP for bakup and Gzip for compression ###################
|
################ 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
|
$GZIP -9 $BKP_FILENAME
|
||||||
|
|
||||||
server1="ftp.cluster011.ovh.net:backup/SilverBook/Bases_MySQL/"
|
server1="ftp.cluster011.ovh.net:backup/SilverBook/Bases_MySQL/"
|
||||||
|
|||||||
Reference in New Issue
Block a user