backup_mysql.sh

-notification (avec terminal-notifier)
-copie sur ovh.net et synology.me
This commit is contained in:
2019-10-25 20:52:20 +02:00
parent dc0dcecdce
commit f2f2053455
2 changed files with 32 additions and 5 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.DS_Store

View File

@@ -55,12 +55,25 @@ IGNORE_DB="information_schema mysql performance_schema"
MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"
GZIP="$(which gzip)"
echo "$MYSQL"
#
notification() {
if [ $3 -eq 0 ];
then
sound="Glass"
message="Envoi terminé sur $2 !"
else
sound="Basso"
message="Echec lors de l'envoi sur $2 : erreur $result"
fi
if [[ "$OSTYPE" == "darwin"* ]] && [ -x "$(command -v terminal-notifier)" ]; then
terminal-notifier -title "$1" -message "$message" -sound "$sound"
fi
}
###################### Get database list ################################
#
DB_LIST="$($MYSQL -u $BKP_USER -h $MYSQL_HOST -p$BKP_PASS -Bse 'SHOW DATABASES')"
echo "$DB_LIST"
#
for db in $DB_LIST
do
@@ -83,7 +96,20 @@ do
$MYSQLDUMP -u $BKP_USER -h $MYSQL_HOST -p$BKP_PASS -r$BKP_FILENAME $db
$GZIP -9 $BKP_FILENAME
scp "$BKP_GZ_FILENAME" funnymac@ftp.cluster011.ovh.net:www/backup/
server="ftp.cluster011.ovh.net:www/backup/"
scp "$BKP_GZ_FILENAME" funnymac@"$server"
result=$?
notification "Backup MySQL: base $db" "$server" $result
sleep 1
server="clicclac.synology.me:/volume1/Backup/SilverBook/Bases_MySQL/"
scp -P42666 -p "$BKP_GZ_FILENAME" bruno@"$server"
result=$?
notification "Backup MySQL: base $db" "$server" $result
fi
done
#########To delete all backup files older then BKP_DAYS #################