Disaster recovering

From OpenKM Documentation
Revision as of 09:28, 27 September 2011 by Pavila (talk | contribs)

Jump to: navigation, search

In case of hardware failure maybe your OpenKM repository became corrupted. In this case you should restore from the last backup (See Backup restoring). But what happen if the backup is missing or even also corrupted? Everything is lost? Well, not exactly. Depending on the kind of disaster you can recover at least the document content.


Nota clasica.png This recovering process will only work if OpenKM is configured to store the document content in a File DataStore.

By default, OpenKM is configured to use a File DataStore. This means thar every document content is stored in the filesystem. This give us very good performance when retrieving document content. But also has a hidden benefit. If your OpenKM installation has been damaged but you can read these DataStore file, you can recover these document contents.

To help up with the process, we have created a simple Bash script:

#!/bin/bash
RESCUE="rescue"
mkdir -p $RESCUE

for DOC in $(find repository/repository/datastore -type f); do
  FILE=$(basename $DOC)
  MIME=$(file -i $DOC | cut -d' ' -f2 | cut -d';' -f1)
  
  if [ $MIME == "text/plain" ]; then
    EXT="txt"
  elif [ $MIME == "application/pdf" ]; then
    EXT="pdf"
  elif [ $MIME == "text/rtf" ]; then
    EXT="rtf"
  elif [ $MIME == "application/vnd.ms-office" ]; then
    EXT="doc"
  elif [ $MIME == "application/vnd.oasis.opendocument.text" ]; then
    EXT="odt"
  elif [ $MIME == "image/gif" ]; then
    EXT="gif"
  elif [ $MIME == "image/png" ]; then
    EXT="png"
  elif [ $MIME == "image/jpeg" ]; then
    EXT="jpg"
  elif [ $MIME == "image/tiff" ]; then
    EXT="tif"
  elif [ $MIME == "application/zip" ]; then
    EXT="zip"
  elif [ $MIME == "application/x-dosexec" ]; then
    EXT="exe"
  elif [ $MIME == "application/octet-stream" ]; then
    EXT="bin"
  else
    EXT=$MIME
  fi
  
  cp -v $DOC $RESCUE/$FILE.$EXT
done

You need to run this script from $JBOSS_HOME directory. All the recovered documents will be copied to the $JBOSS_HOME/rescue directory. This script is only a guide and should be improved to support more MIME types.


Nota clasica.png Recovered document name are not the original ones. They will be like e5de262a84a39f553392751ffd9f4c56796c0029.pdf.