Restoring lost data from a MySQL backup
To restore a backup load the backup database into a seperate database and use PhpMyAdmin to export the right data easily.
We will show you an example of how to restore a single calendar. This way of restoring will leave all existing appointments intact but it will restore lost appointments.
Login to PhpMyadmin and select the backup database. Browse the cal_calendars table and find out the "id" of the calendar you want to store.
Now delete all calendar data that does not belong to that calendar (replace <calendar_id> with your calendar ID):
DELETE FROM cal_events_calendars WHERE calendar_id !=<calendar_id>;
DELETE FROM cal_events WHERE id NOT IN (
FROM cal_events_calendars
DELETE FROM cal_exceptions WHERE event_id NOT IN (
SELECT event_id
FROM cal_events_calendars
);DELETE FROM cal_participants WHERE event_id NOT IN (
FROM cal_events_calendars
DELETE FROM cal_reminders WHERE event_id NOT IN (
SELECT event_id
FROM cal_events_calendars
);
Note: The sub selects in the delete statements only work in MySQL 5.0 or newer. If you have an earlier version you need to perform the select statement manualy and create a comma seperate list of it. You can replace the sub select with that list.
Now we have our data prepared. We need to export the right tables using INSERT IGNORE commands. This will insert only non-existent records.
In PhpMyAdmin click at the Database name at the left frame so that you view all tables in the main screen. Now click at "Export". Select the tables:
- cal_events
- cal_events_calendars
- cal_calendars
- cal_participants
- cal_reminders
- acl
- acl_items
Uncheck the Structure box
Select "IGNORE INSERTS" and "COMPLETE INSERTS"
Select export type "INSERT"
Save the file and load it into your main database make a backup of your database before you do this in case something goes wrong.
