asterisk2billing.org
http://forum.asterisk2billing.org/

How to restore from corrupted DB?
http://forum.asterisk2billing.org/viewtopic.php?f=21&t=7290
Page 1 of 1

Author:  taffey01 [ Sat Mar 13, 2010 2:32 am ]
Post subject:  How to restore from corrupted DB?

Hi Guys,
Got a tricky one here.

I have ver 1.4 up and running in production and most of the features work great. However i'm unable to get DID inbound stuff working and i get high cpu issues in mysql with some of the options for the rates etc. So basically my DB is corrupted somehow. I've tried repairing tables etc but no difference. With a fresh install of 1.6 on another server its all great but as soon as I copy the prod database to the new one it craps out with all the old issues again.

What's my best option for rebuilding to a fresh install of say 1.6 without loosing all the call records and the 12000 rates i have in there?

One option i thought of doing was to run a slave server off the Production one and point the customers to that for call records then build the new 1.6 database from scratch break the master slave replication and then start it working from the new database and recreate the replication and hopefully i'll get all the old call records on the slave for the customers plus the new records off the new DB. However this will take some time as i'll need to reload all the rates and clients again.

My question is - Is there an easier way of doing this?

Grateful for the info.

Thanks,
Taff..

Author:  jroper [ Sat Mar 13, 2010 10:45 am ]
Post subject:  Re: How to restore from corrupted DB?

Hi

Just take a copy of the existing database, and run the update scripts on it.

Joe

Author:  taffey01 [ Sat Mar 13, 2010 10:47 am ]
Post subject:  Re: How to restore from corrupted DB?

Yeah i tried that but got heaps of errors with duplicates etc..

Author:  jroper [ Sat Mar 13, 2010 10:52 am ]
Post subject:  Re: How to restore from corrupted DB?

Hi

The first job is to identify the version of the database, then you need to run the subsequent updates.

However, if you have done this and you are getting duplicates, I'm afraid it is going to get very manual. Open the update scripts in turn, and inspect them and run them manually on by one, because if there is a failure, then the rest of the script is not run.

Joe

Author:  taffey01 [ Sat Mar 13, 2010 10:58 am ]
Post subject:  Re: How to restore from corrupted DB?

Here is an example:

[root@maindb mysql-5.x]# mysql -u root -p mya2billing < UPDATE-a2billing-v1.3.4-to-v1.4.0.sql
Enter password:
ERROR 1050 (42S01) at line 61: Table 'cc_invoice' already exists
[root@maindb mysql-5.x]# mysql -u root -p mya2billing < UPDATE-a2billing-v1.4.0-to-v1.4.1.sql
Enter password:
ERROR 1091 (42000) at line 43: Can't DROP 'currency'; check that column/key exists
[root@maindb mysql-5.x]# mysql -u root -p mya2billing < UPDATE-a2billing-v1.4.1-to-v1.4.2.sql
Enter password:
ERROR 1050 (42S01) at line 34: Table 'cc_message_agent' already exists
[root@maindb mysql-5.x]# mysql -u root -p mya2billing < UPDATE-a2billing-v1.4.2-to-v1.4.3.sql
Enter password:
ERROR 1061 (42000) at line 34: Duplicate key name 'idtariffplan_index'
[root@maindb mysql-5.x]# mysql -u root -p mya2billing < UPDATE-a2billing-v1.4.3-to-v1.4.4.sql
Enter password:
ERROR 1050 (42S01) at line 35: Table 'cc_callplan_lcr' already exists
[root@maindb mysql-5.x]# mysql -u root -p mya2billing < UPDATE-a2billing-v1.4.4.1-to-v1.4.5.sql
Enter password:
ERROR 1060 (42S21) at line 73: Duplicate column name 'agent_id'
[root@maindb mysql-5.x]# mysql -u root -p mya2billing < UPDATE-a2billing-v1.4.5-to-v1.5.0.sql
Enter password:
[root@maindb mysql-5.x]# mysql -u root -p mya2billing < UPDATE-a2billing-v1.5.0-to-v1.5.1.sql
Enter password:
[root@maindb mysql-5.x]# mysql -u root -p mya2billing < UPDATE-a2billing-v1.5.1-to-v1.6.0.sql
Enter password:
ERROR 1146 (42S02) at line 34: Table 'mya2billing.cc_subscription_fee' doesn't exist
[root@maindb mysql-5.x]# mysql -u root -p mya2billing < UPDATE-a2billing-v1.6.0-to-v1.6.1.sql
Enter password:
[root@maindb mysql-5.x]# mysql -u root -p mya2billing < UPDATE-a2billing-v1.6.1-to-v1.6.2.sql
Enter password:

So in each Update file will i have to remove the duplicate lines or ones with errors?

Author:  jroper [ Sat Mar 13, 2010 11:16 am ]
Post subject:  Re: How to restore from corrupted DB?

Hi

Open each file, and copy and paste the individual SQL commands in one by one.

Joe

Author:  taffey01 [ Sat Mar 13, 2010 11:23 am ]
Post subject:  Re: How to restore from corrupted DB?

Ok i'll give that a go.

Cheers...

Author:  taffey01 [ Sat Mar 13, 2010 9:10 pm ]
Post subject:  Re: How to restore from corrupted DB?

Ok that worked a treat for the inbound DID. Now running 1.6.2

The only issue i have left is that when i click on the rates tab under RATES the mysql DB shoots up to 100% cpu and i have to restart the service. No data is presented. Now in ver 1.4.1 i have no issues with it.

Anything i can look at to find this issue? Otherwise i have to keep rolling back to change the rates..

Author:  taffey01 [ Sat Mar 13, 2010 10:30 pm ]
Post subject:  Re: How to restore from corrupted DB?

I get the same issue with the ratecard in the customer portal as well. If i click on it mysql jumps to 100% cpu..

Author:  mtaisigue [ Wed May 05, 2010 4:35 am ]
Post subject:  Re: How to restore from corrupted DB?

hello iam trying to update the data base but iam getting the duplicated error, even when i run one by one command in mysql.

mysql -u root -p mya2billing < UPDATE-a2billing-v1.4.1-to-v1.4.2.sql
Enter password:
ERROR 1050 (42S01) at line 34: Table 'cc_message_agent' already exists

mysql> CREATE TABLE cc_message_agent (
-> id BIGINT NOT NULL AUTO_INCREMENT ,
-> id_agent INT NOT NULL ,
-> message LONGTEXT CHARACTER SET utf8 COLLATE utf8_bin NULL ,
-> type TINYINT NOT NULL DEFAULT '0' ,
-> logo TINYINT NOT NULL DEFAULT '1',
-> order_display INT NOT NULL ,
-> PRIMARY KEY ( id )
-> ) ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
ERROR 1050 (42S01): Table 'cc_message_agent' already exists
mysql>


there is anything else that i need to do?

thank you for your help.

Author:  zlatan24 [ Tue Sep 06, 2011 8:37 pm ]
Post subject:  Re: How to restore from corrupted DB?

taffey01 wrote:
Ok that worked a treat for the inbound DID. Now running 1.6.2

The only issue i have left is that when i click on the rates tab under RATES the mysql DB shoots up to 100% cpu and i have to restart the service. No data is presented. Now in ver 1.4.1 i have no issues with it.

Anything i can look at to find this issue? Otherwise i have to keep rolling back to change the rates..


Given situation may be solved with the aid mysql recovery, which owns many different capabilities for settling out almost every trouble associated with mysql server files.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/