Database Restore

Permalink
So bad things happened, db was not backed up for a month, and users have lost the changes made to their website.

However, I can find all recent files uploaded to the C5 site in the concrete/files directory, even though they don't appear in the FileManager (old db I'm guessing is the reason).

My question is whether it might be possible to rebuild the part of the db that contains links to the files uploaded through FileManager, so that they appear in FileManager again. Would there possibly be some script that might run through the files on the webserver in the /files directory and rebuild that part of the db that lists the files in the FileManager? Am I way off base in how this works?

Thanks
AW

 
Mainio replied on at Permalink Reply
Mainio
Batch processing of the whole /files directory is of course possible but after the processing the file IDs would not match what you used to have in the database. This would break any links and references to these files (e.g. in user attributes or file sets) throughout the site, although you would get them showing back in the file manager.

Depends on the type of files that you're storing whether this matters or not. I would guess for most sites it matters since you wouldn't probably have any reason to upload these files to the site in the first place in case you didn't want to reference them somewhere on that site.

Unfortunately, there is no existing script available for this. Disaster recovery is quite case specific usually and the best approach you can take to it is to have a rock solid backup strategy that is in line with the type of the site and its requirements. Or buy managed hosting and make those guys do it for you (if you want to save your time and energy).
awhite replied on at Permalink Reply
Thanks Mainio,

I still lean toward finding some batch processing resource to restore FileManager file list, even though FileSets and user attributes would be lost. My hope (ever so small) is that users may have named their files in a logical manner and would be able to retrieve files already uploaded by name to re-reference on the site.

And yes, cannot save things now, but we will be learning a lot from this experience and redoubling correct 'rock solid' backup efforts. Its the last time I trust TimeMachine on a Mac to backup a mysql db (or even perform full disk backups).

Are there any resources you know that could batch process the /files directory? If I wanted to write a batch script to do something where would I start? Not sure how to write a bash script that edits a mysqldb.
Mainio replied on at Permalink Reply
Mainio
It's probably easier to create a PHP script to handle this so that you can use the c5 API for doing the actual file adding. Much easier than writing all the queries by hand.

If you're using 5.7, I suggest getting familiar with the command line interface (CLI) in concrete5:
http://documentation.concrete5.org/developers/appendix/cli-commands...

That is just a list of commands available in the system (that are not helpful here) but you can use them as examples to create your own. You can find them from "concrete/src/Console/Command".

The CLI commands are using the Symfony console component that is very well documented:
http://symfony.com/doc/current/cookbook/console/console_command.htm...

If you're using 5.6, I suggest creating a job instead of a CLI command (because they do not exist in 5.6):
http://legacy-documentation.concrete5.org/developers/system/jobs...

For the c5 File API, it's not perfectly documented but some information is available here:

5.7:
http://documentation.concrete5.org/developers/working-with-files-an...

5.6:
http://legacy-documentation.concrete5.org/developers/files/overview...

Other than that, just dig in to the code.