Restauration de base Mysql sur serveur distant

From Tuxunix
Revision as of 13:51, 6 April 2011 by Admin (Talk | contribs) (Created page with ' #!/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 …')

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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