backup_mysql.sh

option contentImage pour terminal-notifier
This commit is contained in:
2019-11-03 09:53:25 +01:00
parent 405bf357ab
commit 259fed4ab2

View File

@@ -23,6 +23,7 @@
# #
BKP_USER="mysqlbackupuser" # Enter the username for backup BKP_USER="mysqlbackupuser" # Enter the username for backup
BKP_PASS="$(cat $HOME/.password.txt)" # Enter the password of the backup user BKP_PASS="$(cat $HOME/.password.txt)" # Enter the password of the backup user
BKP_BASE_DIR=$(dirname "$0")
# #
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
@@ -73,13 +74,15 @@ notification() {
then then
sound="Glass" sound="Glass"
message="Envoi terminé sur $2 !" message="Envoi terminé sur $2 !"
image="$BKP_BASE_DIR/success.png"
else else
sound="Basso" sound="Basso"
message="Echec lors de l'envoi sur $2 : erreur $result" message="Echec lors de l'envoi sur $2 : erreur $result"
image="$BKP_BASE_DIR/error.png"
fi fi
if [[ "$OSTYPE" == "darwin"* ]] && [ -x "$(command -v terminal-notifier)" ]; then if [[ "$OSTYPE" == "darwin"* ]] && [ -x "$(command -v terminal-notifier)" ]; then
terminal-notifier -title "$1" -message "$message" -sound "$sound" terminal-notifier -title "$1" -message "$message" -sound "$sound" -contentImage "$image"
fi fi
} }
@@ -108,7 +111,7 @@ do
$GZIP -9 $BKP_FILENAME $GZIP -9 $BKP_FILENAME
server1="ftp.cluster011.ovh.net:www/backup/SilverBook/Bases_MySQL/" server1="ftp.cluster011.ovh.net:www/backup/SilverBook/Bases_MySQL/"
#scp "$BKP_GZ_FILENAME" funnymac@"$server1" scp "$BKP_GZ_FILENAME" funnymac@"$server1"
result=$? result=$?
notification "Backup MySQL: base $db" "$server1" $result notification "Backup MySQL: base $db" "$server1" $result
@@ -116,9 +119,9 @@ do
sleep 1 sleep 1
server2="clicclac.synology.me:/volume1/Backup/SilverBook/Bases_MySQL/" server2="clicclac.synology.me:/volume1/Backup/SilverBook/Bases_MySQL/"
#scp -P42666 -p "$BKP_GZ_FILENAME" bruno@"$server2" scp -P42666 -p "$BKP_GZ_FILENAME" bruno@"$server2"
result=$? result=$?
notification "Backup MySQL: base $db" "$server2" $result notification "Backup MySQL: base $db" "$server2" $result
fi fi