User Tools

Site Tools


faq:mac:backup_error

Backup Error on Mac OS X

The automatic GECAMed backup process produces some errors on Mac OS X.
Although the database and file backups are done, the old backups aren't deleted afterwards, which can lead to a full disc / empty disc space. What again will prevent GECAMed from doing new backups.
Also the dicom and letter backups aren't done automatically, anymore. The manual backup via GECAMed Client is still working.

The Bug will be fixed in the next release (>= 2.01.03).
Until then you will need to do the backups and delete the old backups regularly. You can do this manually or with a script.

Here's a script example, how to backup the gecamed files:

#!/bin/sh

BACKUP_DIR=/Applications/GECAMed/gecamed_backup
GECAMED_DATA_DIR=/Applications/GECAMed/gecamed_data

FILE_NAME=gecamed_$(date "+%Y_%m_%d_%H_%M_%S")


zip_gecamed_data () {
  SUB_DIR=$1
  FILE_EXTENSION=$2
  
  # v is for verbose, to show which files are added to the zip file.
  #   Removing it will not change the bahaviour, you will simply have less output 
  #   on the console.
  # 9 is the degree of compression, where 9 is the highest and 0 is no compression.
  #   Having no compression will make the zipping faster, but enlarges the size of 
  #   the zip file.
  zip -rv9 $BACKUP_DIR/$FILE_NAME.$FILE_EXTENSION $SUB_DIR
}

cd $GECAMED_DATA_DIR

# backup the attached patient files
# outcommented, because this backup still works
#zip_gecamed_data "patient_files" "filezip"

# backup the letter templates
zip_gecamed_data "template_dir" "lettertemplatezip"

# backup the patient DICOM files
zip_gecamed_data "dicom_dir" "dicomzip"

And here an example, how to delete the oldest backup files:

#!/bin/sh

MAX_FILES=10
BACKUP_DIR=/Applications/GECAMed/gecamed_backup

delete_oldest () {
  FILE_EXTENSION=$1
  MAX=$2
  CURRENT=0
  
  ls -1t *.$FILE_EXTENSION | while read line
  do 
    ((CURRENT++))
    if [[ $CURRENT -gt $MAX ]]
    then
      echo "deleting: $line"
      rm $line
    fi
  done
}

cd "$BACKUP_DIR"
delete_oldest pgdump $MAX_FILES
delete_oldest filezip $MAX_FILES
delete_oldest dicomzip $MAX_FILES
delete_oldest lettertemplatezip $MAX_FILES

GECAMED_DATA_DIR defines the folder, where the files are stored. You can look the folder up in the file “gecamed_server.properties” under “«GECAMed Install Dir»/jboss-4.0.5.GA/server/default/conf”. The default is “/Applications/GECAMed/gecamed_data”
MAX_FILES defines, how many backups of each type shall be preserved (in this case 10).
BACKUP_DIR defines the folder, where the backups are stored. The default is /Applications/GECAMed/gecamed_backup. This folder can be looked up in “gecamed_server.properties” as well.
Make sure you have enough rights to list and delete these files. You might have to call the script as root (using sudo).

To automatically execute these scripts. you can use crontab or a launch daemon.

faq/mac/backup_error.txt · Last modified: 2015/01/23 14:06 by ferringj