anvc / scalar

Born-digital, open source, media-rich scholarly publishing that’s as easy as blogging.
Other
231 stars 73 forks source link

Restoring from a catastrophe with only database backups and the media folder #178

Closed rcrath closed 3 years ago

rcrath commented 3 years ago

Hi, I had a catastrophe and lost my scalar install with all the backups (two local hard disk fails, backup company abruptly stopped supporting linux, errant dean deleted the actual site. I have reconstructed the database backups from the broken hard drives and have most of the images in the media folder. I am after one book as a test case and imported that book's book ID, Contents, user (just me) and user books. I have gotten things to line up and show up in scalar as far as the book appearing in the dashboard, with me as the author. Although the "foreign" bookID in the content table and the "referent" book id in the books table are the same, I have been unable to get the content to show. Would this be possible to repair? This particular project has been worked on by dozens of student and myself for years and was just about ready to release when it got deleted.

the site is at http://udigix.net/scalar2/souls-of-black-folk/index

To recap, the book title is read, along with the user attached to the book, but no pages are seen nor media. The page content is in the database and the media is in the /media folder.

LMK is you need more info on the install or anything. It is an uptodate fresh install of scalar on reclaim hosting if that helps.

eloyer commented 3 years ago

Sorry to hear this!! My sense is that rather than trying to restore the database piecemeal, you're probably better off exporting and then importing the entire database in one go, essentially swapping your current Reclaim Scalar database with the exported one. Reclaim may be able to give you some guidance about how to go about this in their system.

rcrath commented 3 years ago

@eloyer , Thanks, that makes sense and was the first way I tried, but the database sql dump is messed up. I have not been able to find a clean one yet. My backups are all recovered from a failed disk. THey import with errors and then have duplicates in the primary keys, so I was having three of everything and unable to edit anything because of the primary dupes. Plus the UI fails on this data, so I am thinking making the problem smaller is my best hope, since I am most interested in recovering this single project.

Rather than swapping the whole database, I got farther with getting a working scalar with a fresh database and then just using the insert statements contained in the database table dumps for one book, user, content combo and seeing if I broke the install at each step. I was also able to insert just the content and user info just for the one book to simplify the issue as the whole database has a hundred or so books, most of which I am not interested in. That way I could check that all the content belongs to book_id 26 authored by user 1. That way I am pretty sure none of this data is corrupted and I know it has no dupes. I also put in the other tables but was not able to pick out the data just for the one book so all the records for the relationship tablesgot inserted.

I'd be willing to try subbing the whole database again, but I would have to find an uncorrupted version first.

When the empty scalar home page loads, all formatted correctly, just without the data from the content table plugged in, It throws a bunch of PHP errors that all say Message: Attempt to assign property '[FIELDNAME] of non-object where the brackets are subbed for various fields that are not fetching. That seems to be something to do with Code Igniter, of which I know nothing.

When I load the dashboard, media and content give the correct number of items at the top, but do not load any of them into the dashboard overview pages.

rcrath commented 3 years ago

My guess is that for some reason, the database connection fails for the content and media but not for book ID or User (or Book Users). It might be a scalar version thing since this was from a 2019 version of scalar. Or maybe a PHP 7 problem?

eloyer commented 3 years ago

Can you post some of the field names that appear in the error messages?

rcrath commented 3 years ago

Yes, sorry for the delay...I found a better set of data but still have the same problem.. I am attaching a text file with the php generated scalar page of the home page of the book.. All the errors are in the file if you open it as text. The page is at http://udigix.net/scalar2/the-souls-of-black-folk/index if it would help to look around. I have student names in the database so I can't share that or I would.
SOBFHomePage.txt

rcrath commented 3 years ago

Looking closer, I am seeing that there is missing data still, so let me try inserting several of the sql backups instead of just one doing 'INSERT IF NOT EXIST` statements to see if I can get a complete set. That may be the problem, since one or two scalar books, in particular a really simple one, show up fine.

rcrath commented 3 years ago

@eloyer, I was able to retrieve a lot more data and think I have a close to complete set for the site. The text for the book I am trying to recover is back, which is huge! Still have some data massaging and perl oneliners to do to fix some stray urls but it is mostly in working order. What I ended up doing was getting a local copy of the database filled by going through and massaging all the data, stripping out everything but insert ignore into statements and just bisected the files using the error messages.It took a solid day and a half, but then once I had a good db locally I was able to import it smoothly all at once, as you suggested. .

eloyer commented 3 years ago

Excellent, glad to hear this!