Hi all,

We use SugarCRM to manage and recruit current and new employees for our company. We've been doing this for the past year running version xxxx

A few days ago someone made a few mistakes causing a lot of contact info to be deleted and asked me (current/new application manager) to restore a backup.

The engineer that (heavily) modified SugarCRM for our needs is no longer active in the company. He left behind a backup "system" where every day the physical PHP files (contents of htpdocs/sugarcrm/) and the SQL files (mysql/data/sugarcrm/) are incrementally exported to several locations. I was a bit surprised by this method since I though SQL never saves the complete database as physical files. Turns out I was right but I didn't act on it.

So I "restored" the backup by simply copying the SQL files from the backup to the live SQL data folder. The result? SQL errors all over the place and I'm now unable to go back to a working situation..

When clicking "Repair database" it says that there is a difference between the database and the vardefs and that a script needs to be executed. After executing it says:

Executing repair query: Query Failed:ALTER TABLE opportunities add column id char(36) NOT NULL , add column name varchar(50) NULL , add column date_entered datetime NULL , add column date_modified datetime NULL , add column modified_user_id char(36) NULL , add column created_by char(36) NULL , add column description text NULL , add column deleted bool DEFAULT '0' NULL , add column assigned_user_id char(36) NULL , add column opportunity_type varchar(255) NULL , add column campaign_id char(36) NULL , add column lead_source varchar(50) NULL , add column amount double NULL , add column amount_usdollar double NULL , add column currency_id char(36) NULL , add column date_closed date NULL , add column next_step varchar(100) NULL , add column sales_stage varchar(25) NULL , add column probability double NULL , ADD INDEX idx_opp_name (name), ADD INDEX idx_opp_assigned (assigned_user_id)::MySQL error 1033: Incorrect information in file: '.\gate\opportunities.frm'
That's Error #1.
When I try to open a contact or account it loads the profile for 90%, at the bottom it says:

Error running count query for Account List: Query Failed SELECT count(*) c FROM tasks where ( tasks.parent_id= 'b27f6362-e6cd-df92-3102-4934f9b0da1a' AND tasks.parent_type='Accounts' AND tasks.deleted=0 AND (tasks.status='Completed' OR tasks.status='Deferred')) AND tasks.deleted=0 ) UNION ALL ( SELECT count(*) c FROM meetings where ( meetings.parent_id= 'b27f6362-e6cd-df92-3102-4934f9b0da1a' AND meetings.parent_type='Accounts' AND meetings.deleted=0 AND (meetings.status='Held' OR meetings.status='Not Held')) AND meetings.deleted=0 ) UNION ALL ( SELECT count(*) c FROM calls where ( calls.parent_id= 'b27f6362-e6cd-df92-3102-4934f9b0da1a' AND calls.parent_type='Accounts' AND calls.deleted=0 AND (calls.status='Held' OR calls.status='Not Held')) AND calls.deleted=0 ) UNION ALL ( SELECT count(*) c FROM notes where ( notes.parent_id= 'b27f6362-e6cd-df92-3102-4934f9b0da1a' AND notes.parent_type='Accounts' AND notes.deleted=0) AND notes.deleted=0 ) UNION ALL ( SELECT count(*) c FROM emails INNER JOIN emails_beans ON (emails.id=emails_beans.email_id AND emails_beans.bean_id= 'b27f6362-e6cd-df92-3102-4934f9b0da1a' AND bean_module='Accounts') where ( emails_beans.deleted=0 AND emails.deleted=0) AND emails.deleted=0 ) UNION ALL ( SELECT count(*) c FROM emails JOIN (select distinct email_id from emails_email_addr_rel eear join email_addr_bean_rel eabr on eabr.bean_id ='b27f6362-e6cd-df92-3102-4934f9b0da1a' and eabr.bean_module = 'Accounts' and eabr.email_address_id = eear.email_address_id and eabr.deleted=0 where eear.deleted=0 and eear.email_id not in (select eb.email_id from emails_beans eb where eb.bean_module ='Accounts' and eb.bean_id = 'b27f6362-e6cd-df92-3102-4934f9b0da1a' and eb.deleted=0) ) derivedemails on derivedemails.email_id = emails.id where emails.deleted=0 )::MySQL error 1054: Unknown column 'eb.email_id' in 'field list'
I am not, officially, stuck. Can someone make sense of this?

Thanks in advance,
Mike.