Annonce ToutSurTout

Bienvenue sur toutsurtout.biz

Déjà 15 ans !

Radio TST

Si vous souhaitez participer vous aussi aux discussions sur le forum, il faut vous inscrire ou vous identifier.

Le Thème TST Automne est maintenant en place.

Les inscriptions sont actuellement OUVERTES.

Message 1 Discussion postée le 04-12-2010 à 20:03:32

Loic
Avatar de Loic


Titre: Administrateur d'élite
Avancement: Niveau 5
Lieu: Avec Solenne
Date d'inscription: 26-09-2009
Messages: 107 780
Site web

Transferts via SSH

Code :

## INFOS MYSQL ## LOGIN=root # Login for mysql PASS=toto # Pass for mysql ## SSH SERVER FOR TRANSFERT & REINJECTION ## MYSQLSRV2="192.168.0.1" ## Email ## ADMINMAIL=user@fqdn.com # This is the mail were the transferts failures will be notified ## Vars ## TMPDIR=/tmp/baksql # Temp directory ## DO NOT MODIFY NOW ## mkdir $TMPDIR # Backuping databases for databases in "bugzilla" "cacti" "mysql" "networkdb" "wiki" ; do mysqldump -u$LOGIN -p$PASS $databases > $TMPDIR/$databases-'date +%y%m%d'.sql && baksql=$baksql'echo "Sauvegarde de la base $databases - OK ; "' || baksql=$baksql'echo "Sauvegarde de la base $databases - FAILED ; "' done # Transfering databases to the other SQL server (need ssh key) tar -czf $TMPDIR/mysql_backup.tgz $TMPDIR/*.sql scp $TMPDIR/mysql_backup.tgz $MYSQLSRV2:~/ ssh $MYSQLSRV2 tar -xzvf ~/mysql_backup.tgz for databases in "bugzilla" "cacti" "mysql" "networkdb" "wiki" ; do ssh $MYSQLSRV2 "mysql -u$LOGIN -p$PASS $databases < ~/tmp/baksql/$databases-'date +%y%m%d'.sql" && baksql=$baksql'echo "Reinjection de la base $databases - OK ; "' || baksql=$baksql'echo "Reinjection de la base $databases - FAILED ; "' done # Delete temps ssh $MYSQLSRV2 rm -Rf /root/tmp/baksql ~/mysql_backup.tgz ~/tmp rm -Rf $TMPDIR # Send mail echo $baksql | mail -s "Mysql transferts" $ADMINMAIL

http://www.toutsurtout.biz/img/UserBarTST.gif
http://www.toutsurtout.biz/img/Sign-Loic.gif
Loic DL un jour, Loic DL toujours ...