Topic: Database Crash - Lost users - A few questions

Late yesterday evening, this happened:


File: /var/www/html/board/include/functions.php
Line: 45

PunBB reported: Unable to fetch user information

Database reported: Can't open file: 'punbb_users.MYI' (errno: 145) (Errno: 1016)

So, spoke to my site host and they stated:


The table punbb_users in your database had crashed, so I ran the "REPAIR" command from your MySQLAdmin section and now this is fixed.

Thank you,

Regards,

Site is back up and running, however, 2 long standing members have disappeared and all their posts have gone too.

A week back, I did back up (via the control panel of my host/site) the user list. Question I have is, can I use this list and implmement it over the current list - and if I do so will it cause more problems? Will it bring back the two missing members and their lost posts?

Re: Database Crash - Lost users - A few questions

Assuming the backup is a backup of your database, yes, but you'll need to edit it so that you're only restoring the two users.

Re: Database Crash - Lost users - A few questions

If I wanted to restore the database, from one week ago - can I do so by just restoring that one file? Or do I also restore the users list too? I know I will lose the past weeks posts etc, but thats not too much of a concern.

Re: Database Crash - Lost users - A few questions

Assuming the backup is of all your PunBB tables, yes, restoring it would restore your forum to the state it was when it was backed up.
However, since only the users table crashed, you should only need to restore two rows. In fact, if you sent me a copy of the backup (smartys@ this site) and told me which usernames to look for, I should be able to give you the two queries to run to add them back.

Re: Database Crash - Lost users - A few questions

Smartys, thanks.

So restoring the rows would add back the two users and all their posts? Which backup are you refering to? The user list?

Re: Database Crash - Lost users - A few questions

Well, since only the users table crashed, the posts should still exist in the database. The only thing you need to do is add the users back with the proper IDs.
And the backup I'm referring to is the one you have been referring to (I'm not sure what you mean by backing up the user list though, you backed up the users table?)

Re: Database Crash - Lost users - A few questions

Yeah, sorry mate.....I sound a bit daft. Not at home at the moment, and my terminology sucks trying to explain this. But yeah, in my control panel you can back up the database and the users table. Not sure on the file size of the users table.

I'll check once home, and hopefully email you the backup and the two missing usernames.

If this works out, you are a life saver....!!

Re: Database Crash - Lost users - A few questions

Mmmm. Looks like maybe I didnt back up the user tables specifically.

What I have is as follows:

Within my control panel, under 'Backup Data' I have the option to back up the site and back up users.

The site backup is 40.2Mb.
The user back up is....236Mb.

These backups were made via the main control panel options and not the MySQL admin pages.


Not sure if the user back up includes the tables you are referring too. Anything you can recommend?

Re: Database Crash - Lost users - A few questions

Oh, I don't think that refers to PunBB, I think that refers to your control panel users.
And I don't know if your site backup includes a database backup.

10

Re: Database Crash - Lost users - A few questions

I unzipped the user back up. Its full of punbb posts. Includes even someone (a former admin) who deleted himself an age ago.


Examples:

INSERT INTO `punbb_posts` VALUES (17970, 'treelo', 38, '80.193.181.235', NULL, 'sell outs\r\n\r\nthats all spurs are', 0, 1140456042, NULL, NULL, 2193);
INSERT INTO `punbb_posts` VALUES (17971, 'treelo', 38, '80.193.181.235', NULL, 'first roasting on the season?', 0, 1140456083, NULL, NULL, 2207);
INSERT INTO `punbb_posts` VALUES (17972, 'Elzar', 3, '212.32.107.22', NULL, 'True. Apart from the Stacki bit.\r\n\r\nLike i said we''ll have to stop our own trolling, and learn to ignore rather than ''bite''. I still can''t have respect for someone that types ''u'' instead of ''you'' though.\r\n\r\nWe can hide the post counts on PunBB. Maybe little things like that will stop cliques?', 0, 1140456501, NULL, NULL, 1631);

Re: Database Crash - Lost users - A few questions

Interesting smile
That would be a database backup, that should have what you need to restore.

12

Re: Database Crash - Lost users - A few questions

Well, since only the users table crashed, the posts should still exist in the database. The only thing you need to do is add the users back with the proper IDs.

So, what needs to be done, guv? smile

Re: Database Crash - Lost users - A few questions

Email me a copy of the backup

14

Re: Database Crash - Lost users - A few questions

problem is, the file is huge. 236mb. dont see how i can email it sad

Re: Database Crash - Lost users - A few questions

OK, look for the lines that start
INSERT INTO `punbb_users`
and have the missing usernames in them. There should be two of them. Run those two queries.

16 (edited by nick23 2007-06-21 19:21)

Re: Database Crash - Lost users - A few questions

Righto,

Via SQL, entered the following:


INSERT INTO `punbb_users` VALUES (5, 4, 'Dandy', '', '', 'Got Ears?', NULL, NULL, NULL, NULL, 'golXXXXXend@hotmail.com', NULL, NULL, 'Seat BB105, Upper Deck, Dick D', 0, 'Hate is baggage. Life''s too short to be pissed off all the time.', NULL, NULL, 1, 1, 0, 1, 1, 1, 1, 1, 1, 'English', 'Oxygen', 826, 1150221176, 1123433477, '0.0.0.0', 1150229329, NULL, NULL, NULL);

hit go. got the following response:



SQL query:

INSERT INTO `punbb_users`
VALUES ( 5, 4, 'Dandy', '', '', 'Got Ears?', NULL , NULL , NULL , NULL , 'goldiethelXXXXgend@hotmail.com', NULL , NULL , 'Seat BB105, Upper Deck, Dick D', 0, 'Hate is baggage. Life''s too short to be pissed off all the time.', NULL , NULL , 1, 1, 0, 1, 1, 1, 1, 1, 1, 'English', 'Oxygen', 826, 1150221176, 1123433477, '0.0.0.0', 1150229329, NULL , NULL , NULL ) ;

MySQL said:
#1136 - Column count doesn't match value count at row 1

A mate is saying that there is a fundamental problem between the two, probably a missing field. I'm a bit lost in understanding how to translate any of the above into table format to work out what the missing element is.


/scratches head

Re: Database Crash - Lost users - A few questions

Indeed
Run

describe punbb_users

and I'll see if I can figure out what's missing/what goes where wink

18 (edited by nick23 2007-06-21 20:01)

Re: Database Crash - Lost users - A few questions

id -----------------                 int(10) unsigned             PRI      NULL      auto_increment
group_id  -----------------      int(10) unsigned                 4     
username  -----------------     varchar(200)           MUL           
password  -----------------     
email      -----------------           varchar(50)                       
title      -----------------             varchar(50)     YES           NULL     
realname ----------------- varchar(40)     YES           NULL     
url -----------------                 varchar(100)     YES           NULL     
jabber -----------------               varchar(75)     YES           NULL     
icq      -----------------            varchar(12)     YES           NULL     
msn      -----------------           varchar(50)     YES           NULL     
aim      -----------------           varchar(30)     YES           NULL     
yahoo      -----------------           varchar(30)     YES           NULL     
location      -----------------  varchar(30)     YES           NULL     
use_avatar      ----------------- tinyint(1)                 0     
signature      -----------------  text     YES           NULL     
disp_topics      -----------------  tinyint(3) unsigned     YES           NULL     
disp_posts      -----------------  tinyint(3) unsigned     YES           NULL     
email_setting  -----------------      tinyint(1)                 1     
save_pass      -----------------   tinyint(1)                 1     
notify_with_post      ----------------- tinyint(1)                 0     
show_smilies      ----------------- tinyint(1)                 1     
show_img      ----------------- tinyint(1)                 1     
show_img_sig      ----------------- tinyint(1)                 1     
show_avatars      ----------------- tinyint(1)                 1     
show_sig      ----------------- tinyint(1)                 1     
timezone      ----------------- float                 0     
language      ----------------- varchar(25)                 English     
style             -----------------   varchar(25)                 Oxygen     
num_posts      ----------------- int(10) unsigned                 0     
last_post      ----------------- int(10) unsigned     YES           NULL     
registered      ----------------- int(10) unsigned           MUL     0     
registration_ip      ----------------- varchar(15)                 0.0.0.0     
last_visit            -----------------   int(10) unsigned                 0     
admin_note        -----------------  varchar(30)     YES           NULL     
activate_string      ----------------- varchar(50)     YES           NULL     
activate_key         ----------------- varchar(8)     YES           NULL     
karma      ----------------- int(20)                 0     
read_topics      -----------------               mediumtext     YES           NULL     
reputation_enable      -----------------          smallint(6)     YES           1     
reputation_enable_adm      -----------------       tinyint(1) unsigned     YES           1

Re: Database Crash - Lost users - A few questions

INSERT INTO `punbb_users`
VALUES ( 5, 4, 'Dandy', '', 'goldieXXXXnd@btinternet.com', 'Got Ears?', NULL , NULL , NULL , NULL , 'goldiethelXXXXgend@hotmail.com', NULL , NULL , 'Seat BB105, Upper Deck, Dick D', 0, 'Hate is baggage. Life''s too short to be pissed off all the time.', NULL , NULL , 1, 1, 0, 1, 1, 1, 1, 1, 1, 'English', 'Oxygen', 826, 1150221176, 1123433477, '0.0.0.0', 1150229329, NULL , NULL , NULL, 0, NULL, 1, 1) ;

Tell me when you do it so I can remove the password hash wink

Basically, you had 4 new columns. I just added values for them to the end of the query. (0, NULL, 1, 1)

20

Re: Database Crash - Lost users - A few questions

Mate, run that....seems to work. Its restored that particular user smile

2 users to go....

21

Re: Database Crash - Lost users - A few questions

Morning.

Thanks for your help on this.

Added back the two missing users. Interestingly, on the face of it, their old posts (going back to when the forum first went live) and their most recent all appear to be there, yet their post count would reflect otherwise, so it would seem that some posts have gone missing - but this doesnt worry me too much.

On the back of this, I used the query you suggested on another user. This particular person was, in a word, a git. A former admin, he through a hissy fit and deleted himself.

Now, in the backup, I can see this users posts. Within SQL, I can find the user. Having run the query, it appears that he has been added back (at least when the query is run, SQL doesnt return an error) but he doesnt appear on the forum.

The prob is, I cant find any posts within SQL made by him - which is whats confusing me if I can see his posts in the backup.

Not sure if anyone has any suggestions on this....?

Re: Database Crash - Lost users - A few questions

Added back the two missing users. Interestingly, on the face of it, their old posts (going back to when the forum first went live) and their most recent all appear to be there, yet their post count would reflect otherwise, so it would seem that some posts have gone missing - but this doesnt worry me too much.

Their post count is stored in the users table, so what you see of it reflects how old the backup is

The prob is, I cant find any posts within SQL made by him - which is whats confusing me if I can see his posts in the backup.

He deleted his posts in your forum. Unless you restore his posts from the backup, you won't see the posts, because they don't exist anymore.

23

Re: Database Crash - Lost users - A few questions

Cheers once more.

With the post count, do you mean that the count itself is simply incorrect and that their actual posts all still remain in tact?

Re: Database Crash - Lost users - A few questions

With the post count, do you mean that the count itself is simply incorrect and that their actual posts all still remain in tact?

Yes, the count is not calculated every time based on the number of posts in the database. It is simply incremented when a user makes a post. Since your backup is somewhat old, the users have whatever post count they had when the backup was taken

25 (edited by nick23 2007-06-22 12:23)

Re: Database Crash - Lost users - A few questions

That makes sense.

With restoring posts from a backup so they reappear - is this quite simple to do?

Current database has no posts by him in the backup.

An older database appears to have posts by him. Can these be used?

I'm actually now using SQL tools to back up the users table and the database. Interestingly, the backup made a week back via the control panel does include his legacy 'deleted' posts. Weird.