Bash script to detect and repair mysql tables automatically?

  • Thread starter Thread starter postcd
  • Start date Start date
P

postcd

Hi,

sometimes (rare case) happen that a mysql table got "crashed" and so the website stop working.

so my idea is to create bash script which will run hourly/daily (welcome advice) and check all databases tables on linux server. If table is crashed, it will try to fix it and also send an email to admin. Email: "It appears that table $tablename" in $dbname database was crashed and there was an attempt to repair it. Please check if corresponding website works."

this checks all dbs and autorepair
Code:
mysqlcheck -u [username] -p[password] --all-databases --check --auto-repair
aditional parameters:
Code:
-C, –check-only-changed Check tables that are changed since last check
-F, –fast Check tables that are not closed properly
-r, –repair Fix the table corruption
..The task should be take minimum server resources..

But if i want to mail an crashed/repaired mysql table name as an variable, im unsure how to extract this name from mysqlcheck output

any ideas pls? or is there any already made script?


------
There is an optimisation script: http://www.lxg.de/code/shell-script-...atabases-mysql

Continue reading...
 
Back
Top