~ovais-tariq/percona-data-recovery-tool-for-innodb/percona-data-recovery-tool-for-innodb

« back to all changes in this revision

Viewing changes to recovery_reload_tables.sh

  • Committer: Ovais Tariq
  • Date: 2013-04-13 12:18:03 UTC
  • Revision ID: ovaistariq@gmail.com-20130413121803-3ks0hygadalv8jjt
Added custom scripts to aid in automating recovery

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
 
 
3
# (c) 2012, Ovais Tariq <ovaistariq@gmail.com>
 
4
#
 
5
# This program is free software: you can redistribute it and/or modify
 
6
# it under the terms of the GNU General Public License as published by
 
7
# the Free Software Foundation, either version 3 of the License, or
 
8
# (at your option) any later version.
 
9
#
 
10
# This program is distributed in the hope that it will be useful,
 
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
# GNU General Public License for more details.
 
14
#
 
15
# You should have received a copy of the GNU General Public License
 
16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
 
 
18
db=$1
 
19
dump_dir=$2
 
20
mysql_user=root
 
21
mysql_pass=
 
22
 
 
23
# Create the database if it does not exists
 
24
mysql --user=$mysql_user --password=$mysql_pass -e "CREATE DATABASE IF NOT EXISTS \`${db}\`"
 
25
 
 
26
for dump_filename in $(grep "completed successfully" ${dump_dir}/${db}-dump.log | awk '{print $5}' | sed "s/${db}./${db}\//")
 
27
do
 
28
    dump_filename=${dump_dir}/${dump_filename}.dump
 
29
 
 
30
    {
 
31
    echo
 
32
    echo "--- Reloading table $dump_filename"
 
33
    mysql --user=$mysql_user --password=$mysql_pass $db < $dump_filename
 
34
 
 
35
    if [[ $? != 0 ]]
 
36
    then
 
37
        echo "--- Failed to reload table $dump_filename"
 
38
    else
 
39
        echo "--- Reload of table $dump_filename completed successfully"
 
40
    fi
 
41
    } >> ${dump_dir}/${db}-reload.log
 
42
done