Restauration de base Mysql sur serveur distant

From Tuxunix
Jump to: navigation, search
#!/bin/sh

file=$(ls -rht /var/backups/mysql/ |  grep wiki | tail -1)

scp /var/backups/mysql/${file} root@XXXX:/root/
sleep 1
ssh root@XXXXX "bunzip2 /root/${file}"
ssh root@XXXXX "mysql --defaults-file=/etc/mysql/debian.cnf -D wikidb < /root/${file:0:19}"
if [ "$?" == "0" ]; then
       echo "$(date) => Restauration DB wikidb Ok" >/var/log/copyDB.log
       ssh root@XXXXX "rm /root/${file:0:19}"
else
       echo "$(date) => Restauration DB wikidb Error" >/var/log/copyDB.log
fi