(HSQLDB + Linux) Power outage leads to data loss - how to recover?
PostPosted:Fri Aug 28, 2015 10:12 pm
Synopsis: how to recover lost files, after a power outage/bad shut down of a misconfigured community OpenKM installation under Linux (Debian).
Scenario: For some strange reason your mission critical OpenKM installation is using the default HSQLDB rather than SQL. Also unknown to you, the system shutdown scripts, triggered by your battery backup UPC, don't give Tomcat & OpenKM enough time to shutdown properly.
So one day you have a power outage. Everything seems fine, until at startup, you notice that seven days of work in OpenKM is missing. (or at least since the last time you properly shutdown Tomcat to do a backup)
(Please let me know if there's a better way to do this. I just figured out this method of recovering my work, and it truly saved me a lot a grief!)
Solution: the default HSQLDB appears to store the database organizing your OpenKM repository in RAM only, until a proper shutdown/restart. At restart, it will appear in OpenKM that your latest documents are missing! But the actual pdf files are still there in the repository "datastore" folder. How to find them all, and copy them to a recovery directory to get re-filed by hand in the OpenKM front-end:
# find [REPO-PATH] -ctime -[days-since-backup + 1] -type f ! -name "*.*" -exec cp --preserve=timestamps '{}' [TEMP-RECOVERY-DIRECTORY] \;
or in my case...
# find /repository -ctime -8 -type f ! -name "*.*" -exec cp --preserve=timestamps '{}' /home/recovery/ \;
This searches your repository for your missing pdf files less than # days old (7 in my case). OpenKM saves them using a UUID with no extension, so with out the ! -name "*.*" option you'll accidentally find a bunch of .swf files as well. The -exec part will copy the found files to your temporary recovery directory, while preserving your timestamps so filing will be easier. Once they're there, you'll want them all to have a .pdf extension:
# cd [TEMP-RECOVERY-DIRECTORY]
# find ./ -exec cp --preserve=timestamps '{}' '{}'.pdf \; [changes them all to .pdf while preserving timestamps]
# find ./ ! -name "*.pdf" -exec rm '{}' \; [delete the old copies without .pdf extensions]
I just wanted to share this with the OpenKM community, in case there's one person out there that ever runs into the same situation, with a do-it-yourself OpenKM setup. In my case, it saved me a week's worth of work.
Of course, the best solution is to know what you're doing in the first place, and have a proper setup
...lesson learned, but it wasn't fatal. Now, time to figure out my shutdown scripts, and get things switched over to SQL! Also, OpenKM rocks!
Scenario: For some strange reason your mission critical OpenKM installation is using the default HSQLDB rather than SQL. Also unknown to you, the system shutdown scripts, triggered by your battery backup UPC, don't give Tomcat & OpenKM enough time to shutdown properly.
So one day you have a power outage. Everything seems fine, until at startup, you notice that seven days of work in OpenKM is missing. (or at least since the last time you properly shutdown Tomcat to do a backup)
(Please let me know if there's a better way to do this. I just figured out this method of recovering my work, and it truly saved me a lot a grief!)
Solution: the default HSQLDB appears to store the database organizing your OpenKM repository in RAM only, until a proper shutdown/restart. At restart, it will appear in OpenKM that your latest documents are missing! But the actual pdf files are still there in the repository "datastore" folder. How to find them all, and copy them to a recovery directory to get re-filed by hand in the OpenKM front-end:
# find [REPO-PATH] -ctime -[days-since-backup + 1] -type f ! -name "*.*" -exec cp --preserve=timestamps '{}' [TEMP-RECOVERY-DIRECTORY] \;
or in my case...
# find /repository -ctime -8 -type f ! -name "*.*" -exec cp --preserve=timestamps '{}' /home/recovery/ \;
This searches your repository for your missing pdf files less than # days old (7 in my case). OpenKM saves them using a UUID with no extension, so with out the ! -name "*.*" option you'll accidentally find a bunch of .swf files as well. The -exec part will copy the found files to your temporary recovery directory, while preserving your timestamps so filing will be easier. Once they're there, you'll want them all to have a .pdf extension:
# cd [TEMP-RECOVERY-DIRECTORY]
# find ./ -exec cp --preserve=timestamps '{}' '{}'.pdf \; [changes them all to .pdf while preserving timestamps]
# find ./ ! -name "*.pdf" -exec rm '{}' \; [delete the old copies without .pdf extensions]
I just wanted to share this with the OpenKM community, in case there's one person out there that ever runs into the same situation, with a do-it-yourself OpenKM setup. In my case, it saved me a week's worth of work.
Of course, the best solution is to know what you're doing in the first place, and have a proper setup