Difference between revisions of "Disaster recovering"

From OpenKM Documentation
Jump to: navigation, search
m
Line 5: Line 5:
 
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.
 
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:
+
To help up with the process, we have created a simple Bash script, called '''rescue.sh''':
  
 
<source lang="bash">
 
<source lang="bash">
Line 52: Line 52:
 
{{Note|Recovered document name are not the original ones. They will be like ''e5de262a84a39f553392751ffd9f4c56796c0029.pdf''.}}
 
{{Note|Recovered document name are not the original ones. They will be like ''e5de262a84a39f553392751ffd9f4c56796c0029.pdf''.}}
  
 +
If you have a functional OpenKM installation but want to recover deleted documents from a damaged backup you can also make use of this script. After you have executed the '''rescue.sh''' script you will have a lot of file under the '''rescue''' directory. To remove the document already have in the current OpenKM installation, copy the rescue directory to the working OpenKM installation and execute this script, called '''prune.sh''':
 +
 +
<source lang="bash">
 +
#!/bin/bash
 +
RESCUE="rescue"
 +
 +
for DOC in $(find repository/repository/datastore -type f); do
 +
  FILE=$(basename $DOC)
 +
 +
  if [ -f $RESCUE/$FILE.* ]; then
 +
    rm $RESCUE/$FILE.*
 +
  fi
 +
done
 +
</source>
 
[[Category: Installation Guide]]
 
[[Category: Installation Guide]]
 
[[Category: OKM Network]]
 
[[Category: OKM Network]]

Revision as of 08:44, 27 September 2011

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, called rescue.sh:

#!/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.

If you have a functional OpenKM installation but want to recover deleted documents from a damaged backup you can also make use of this script. After you have executed the rescue.sh script you will have a lot of file under the rescue directory. To remove the document already have in the current OpenKM installation, copy the rescue directory to the working OpenKM installation and execute this script, called prune.sh:

#!/bin/bash
RESCUE="rescue"

for DOC in $(find repository/repository/datastore -type f); do
  FILE=$(basename $DOC)

  if [ -f $RESCUE/$FILE.* ]; then
    rm $RESCUE/$FILE.*
  fi
done