site recovery

site recovery

by Cyber Secrets -
Number of replies: 4

I have a cold backup of a server /var/lib/mysql and /etc/mysql on a moodle site.

The server harddrive crashed before the course and database backups were offloaded.  This was the latest MySQL as of 11/01/2024.  

I installed MySQL and Apache2 on the new server. I've tried copying those over to the new server afterward, but no databases show up. I've tried the assert method to drop and import the tablespaces, which is hit-and-miss per table.  I've tried the binlog recovery method, and many seem to have a bad offset.

Is there a better way to recover the site from a cold backup?  

Average of ratings: -
In reply to Cyber Secrets

Re: site recovery

by Ken Task -
Picture of Particularly helpful Moodlers

Ouch! :|

The database for the moodle is in /var/lib/mysql/DBNAME4MOODLE/

where DBNAME4MOODLE above is/was the name of the DB for the moodle.

That's the only directory one could load into new DB server setup.

In there one should see a bunch of .ibd files.  Example:

-rw-r-----. 1 mysql mysql    81920 Feb  9  2024 mdl_workshop_aggregations.ibd
-rw-r-----. 1 mysql mysql    65536 Feb  9  2024 mdl_workshopallocation_scheduled.ibd
-rw-r-----. 1 mysql mysql    81920 Feb  9  2024 mdl_workshop_assessments.ibd
-rw-r-----. 1 mysql mysql    65536 Feb  9  2024 mdl_workshopeval_best_settings.ibd
-rw-r-----. 1 mysql mysql    65536 Feb  9  2024 mdl_workshopform_accumulative.ibd
-rw-r-----. 1 mysql mysql    65536 Feb  9  2024 mdl_workshopform_comments.ibd
-rw-r-----. 1 mysql mysql    65536 Feb  9  2024 mdl_workshopform_numerrors.ibd
-rw-r-----. 1 mysql mysql    73728 Feb  9  2024 mdl_workshopform_numerrors_map.ibd
-rw-r-----. 1 mysql mysql    65536 Feb  9  2024 mdl_workshopform_rubric_config.ibd
-rw-r-----. 1 mysql mysql    65536 Feb  9  2024 mdl_workshopform_rubric.ibd
-rw-r-----. 1 mysql mysql    65536 Feb  9  2024 mdl_workshopform_rubric_levels.ibd
-rw-r-----. 1 mysql mysql    73728 Feb  9  2024 mdl_workshop_grades.ibd
-rw-r-----. 1 mysql mysql    65536 Feb  9  2024 mdl_workshop.ibd
-rw-r-----. 1 mysql mysql    81920 Feb  9  2024 mdl_workshop_submissions.ibd
-rw-r-----. 1 mysql mysql    81920 May 31 15:03 mdl_xapi_states.ibd

Note the permissions and ownerships on all files.

Good luck!

'SoS', Ken

In reply to Cyber Secrets

Re: site recovery

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Trying to understand what you say:

a. You have a (good) backup of /var/lib/mysql and /etc/mysql
Those are enough to restore the database.
 
A SQL dump would have been easier, but I understand that you haven't taken a database dump.

b. What about moodledata/ directory, specifically moodledata/filedir/?
This had to be taken as you backed up the database in a).

c. What about the moodle code directory, usually just called moodle/?
Ideally backed up at the same time with a) and b). The code is not something changes continuously. So a backup from roughly the same time is good enough.
 
The whole story is documented in Site backup.

Once you have those three things, to restore the Moodle site follow Site restore.
In reply to Cyber Secrets

Re: site recovery

by Ken Task -
Picture of Particularly helpful Moodlers

Found this:

https://dev.mysql.com/doc/mysql-backup-excerpt/8.0/en/innodb-backup.html

Cold Backups

If you can shut down the MySQL server, you can make a physical backup that consists of all files used by InnoDB to manage its tables. Use the following procedure:

Perform a slow shutdown of the MySQL server and make sure that it stops without errors.

Copy all InnoDB data files (ibdata files and .ibd files) into a safe place.

Copy all InnoDB redo log files (#ib_redoN files in MySQL 8.0.30 and higher or ib_logfile files in earlier releases) to a safe place.

Copy your my.cnf configuration file or files to a safe place.

Good luck!

'SoS', Ken