Script de sauvegarde MySQL + transfert FTP

HOST='ftp.host.com'
USER='user'
PASS='pass'
TARGETFOLDER="/remote/path/$(date +%F-%H-%M)"
SOURCEFOLDER='/local/path'

#liste des dossier
LISTEBDD=$( echo 'show databases' | mysql -uuser -ppass )
 
#on boucle sur chaque dossier (for découpe automatiquement par l'espace)
for SQL in $LISTEBDD
 
do
 
if [ $SQL != "information_schema" ] && [ $SQL != "mysql" ] && [ $SQL != "Database" ] && [ $SQL != "phpmyadmin" ] && [ $SQL != "performance_schema" ]; then
 
echo $SQL
mysqldump -uuser -ppass $SQL | gzip > /local/path/$SQL.sql.gz
 
fi
 
done


#Copie FTP
lftp -f "
open $HOST
user $USER $PASS
mirror --reverse --verbose $SOURCEFOLDER $TARGETFOLDER
bye
"

Laisser un commentaire