-
Notifications
You must be signed in to change notification settings - Fork 1
/
restore.all.sh
executable file
·43 lines (32 loc) · 1.1 KB
/
restore.all.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
# Remove the # below for debugging
set -e
#grep -e ^innodb_force_recovery /opt/zimbra/conf/my.cnf
RECOVER_MODE=`awk '/^innodb_force_recovery/ {print $1; exit}' /opt/zimbra/conf/my.cnf | awk -F= '{print $2}'`
if [ "$RECOVER_MODE" != "" ]; then
echo "Please edit /opt/zimbra/conf/my.cnf, remove/comment innodb_force_recovery under section [mysqld], save file and restart mysql: mysql.server restart"
exit
fi
source ~/bin/zmshutil ; zmsetvars
echo "Creating databases"
for db in `cat /tmp/mysql.db.list`
do
mysql -e "create database $db character set utf8"
echo "Created $db"
done
echo "Restoring databases"
mysql zimbra < /tmp/mysql.sql/zimbra.sql
echo -e "Updated zimbra \n"
for sql in /tmp/mysql.sql/mbox*
do
mysql `basename $sql .sql` < $sql
echo -e "Updated `basename $sql .sql` \n"
done
if [ -f "/tmp/mysql.sql/chat.sql" ]; then
mysql chat < /tmp/mysql.sql/chat.sql
echo -e "Updated chat \n"
fi
echo "Verifying the restoration"
mysql zimbra -e "select * from mailbox order by id desc limit 1"
zmcontrol start
echo "Everything done! Check the mail server!"