Quantcast
Channel: Backup and restore
Viewing all articles
Browse latest Browse all 6619

Re: *correction* - Re: Restore with only moodle, moodledata, \var\lib\mysql, and \etc\mysql

$
0
0
by Eric Messick.  

FULL RECOVERY!!!--I can't believe it.

Kept getting database errors re: timing out and other issues due to knowing nothing about DBs...so did a lot of experimenting. I used all the help in this string plus heaps of reading up on mySQL recovery, permissions for mySQL folders and files, and mySQL DB users/permissions. I'm not 100% sure what made the difference in the end.

Here is roughly how the fix unfolded, not too sure if this was the order or if I missed anything.

  • Fresh install of Unbuntu 15.04 on second VPS because that is what I was upgrading to when I crashed. I am clueless if this mattered but I thought the less variables the better.
  • Installed mySQL
  • I think I added innodb_force_recovery = 6 under [mysqld] to mysqld.cnf. Struggled knowing which .cnf file to use because it should have been my.cnf? But got errors with that one. 
  • I probably forgot to "service mysql restart" after changing .cnf file...so remember to do this.
  • I think I copied over the recovered moodle folder with .frm files and the recovered ibdata1 into /var/lib/mysql. I'm pretty sure I didn't copy over the lof files..maybe even deleted them?
  • Don't think I did this but may have also put innodb_log_file_size=XXM, with the "XX" as the size in mb of the original log files I think?
  • To make sure the permissions were OK I temporarily made all of the files and folders 0777 with mysql as group/owner
  • Kept having trouble with these:
    • sudo mysql_upgrade -u root -p --force
    • mysqldump -u root -p moodle > moodlefixed.sql
  • So did this and the dump worked.

mysql -u root -p --execute="SET GLOBAL net_write_timeout=600; SET GLOBAL net_read_timeout=600; SET GLOBAL max_allowed_packet=1073741824; SET GLOBAL connect_timeout=60;"> /dev/null

I restored the dump along with the moodle and moodledata folders onto the original server running a fresh Ubuntu 14.10 (this is where I was when it crashed). I got a database error when going to the moodle site. Tried adding the user and password to the moodle database just as in the moodle install instructions...this proved to be hugely important and it worked right away:

mysql> create user 'PUTUSERNAMEHERE'@'localhost' IDENTIFIED BY 'PUTPASSWORDHERE';

mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO PUTUSERNAMEHERE@localhost IDENTIFIED BY 'PUTPASSWORDHERE';

Take home point to avoid spending 50 hrs on this (but learing a lot along the way): you need to back up moodle, moodledata, and you need to backup the database /var/lib/mysql properly by mysqldump:

 mysqldump -u root --p moodle > /moodlebackup.sql

Thanks for the help Ken, I hope all of this effort helps at least one other person...


Viewing all articles
Browse latest Browse all 6619

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>