8.1 Backup and Restore OpenClinica

This page covers how to backup and restore OpenClinica data on the PostgreSQL database. OpenClinica keeps data needed to run the system in two locations, the actual database and the openclinica.data folder. Note: If changes to either of the variables below (which reference other folders) where made in the datainfo.properties configuration file you will need to backup these folders in your configured location in order to have a complete backup.

  • attached_file_location
  • exportFilePath 

Backup OpenClinica

A full backup of OpenClinica data can be accomplished by the following steps:

  1. Backup the DB
  2. Backup the openclinica.data folder

Backup the DB

Here are the steps for backing up your DB for both Linux and Windows:

Linux

Before you backup the DB stop Tomcat. Once Tomcat has stopped, take a backup of the DB using the "pg_dump" command from PostgreSQL. To accomplish this run the following commands:

  • /etc/init.d/tomcat stop (Confirm Tomcat is stopped before continuing.)
  • /opt/PostgreSQL/8.4/bin/pg_dump -F c -U postgres openclinica > openclinica.backup (When prompted for a password enter your "postgres" DB superusers password.)

You now have a complete backup of your OpenClinica DB. 

In case you need it, here is some pg_dump reference material.

Windows

Before you backup the DB stop Tomcat. Once stopped we will take a backup using the "pg_dump" command from PostgreSQL. To accomplish this run the following commands:

  • Open a command prompt and type "net stop tomcat6" and hit "enter" to stop tomcat.
  • “C:\Program Files (x86)\PostgreSQL\8.4\bin\pg_dump.exe” -F c -U postgres openclinica > openclinica.backup (When prompted for a password enter your "postgres" db superusers password)
    • On 32-Bit editions of windows the path will be the following for pg_dump.exe “C:\Program Files\PostgreSQL\8.4\bin\pg_dump.exe”

You now have a complete backup of your OpenClinica DB.

In case you need it, here is some pg_dump reference material.

Backup the openclinica.data folder

Here are the steps to backup the openclinica.data folder in Linux or Windows:

Linux

The following will create a backup of your openclinica.data folder into the current directory:

  • cp -rf /usr/local/tomcat/openclinica.data .

Windows

The following illustrates how to get a backup of your openclinica.data folder on Windows:

  • Open "My Computer" or "Explorer"
  • Navigate to "c:\oc\tomcat\"
  • Copy the folder labeled "openclinica.data" within"c:\oc\tomcat\" to your backup location.

Restore OpenClinica

Restoring OpenClinica is quite simple. The recommended method is simply follow the OpenClinica installation guide for your OS. Once you have a blank OpenClinica instance ready, use the following steps to restore your data. By installing a blank OpenClinica instance first you can more easily rule out potential problems which may be caused by configuration issues.

The basic steps to restore your data into OpenClinica are:

  1. Install a new blank OpenClinica instance.
  2. Restore the OpenClinica DB from backup.
  3. Restore the openclinica.data folder from backup.

Step 1: Install a new blank OpenClinica instance

Linux

  • Please follow this guide to install a new OpenClinica instance on Linux.

Once you see the OpenClinica login screen you are ready to proceed to Step 2.

Windows

  • Please follow this guide to install a new OpenClinica instance.

Once you see the OpenClinica login screen you are ready to proceed to Step 2.

Step 2: Restore the OpenClinica DB

To restore the OpenClinica DB:

  • Stop Tomcat
  • Drop the current DB
  • Create a new DB
  • Restore your database backup file into the DB

The following describes how to do this for both Linux and Windows:

Linux

Run the following commands:

  • /etc/init.d/tomcat stop (Confirm tomcat is stopped before continuing)
  • /opt/PostgreSQL/8.4/bin/dropdb -U postgres openclinica (When prompted for a password enter your "postgres" db superusers password)
  • /opt/PostgreSQL/8.4/bin/psql -U postgres -c "CREATE DATABASE openclinica WITH ENCODING='UTF8' OWNER=clinica" (When prompted for a password enter your "postgres" db superusers password)
  • "cd" to change directory to where your backup DB file is located.
  • /opt/PostgreSQL/8.4/bin/pg_restore -U postgres -d openclinica < $DBBACKUPFILE  (When prompted for a password enter your "postgres" db superusers password)

The backup of your DB has now been restored.

dropdb - Reference Material

pg_restore - Reference Material

Windows

  • Open a command prompt and type "net stop tomcat6" to stop tomcat.
  • In the command prompt "cd" to the following directory "C:\Program Files (x86)\PostgreSQL\8.4\bin\"
    • On 32-Bit editions of windows the path will be the following “C:\Program Files\PostgreSQL\8.4\bin\”
  • In the command prompt now run the following commands.
    • dropdb -U postgres openclinica (When prompted for a password enter your "postgres" db superusers password)
    • psql -U postgres -c "CREATE DATABASE openclinica WITH ENCODING='UTF8' OWNER=clinica" (When prompted for a password enter your "postgres" db superusers password)
    • pg_restore -U postgres -d openclinica < $DBBACKUPFILE  (When prompted for a password enter your "postgres" db superusers password)

The backup of your DB has now been restored. This can also be done via PGAdminIII.

dropdb - Reference Material

pg_restore - Reference Material

Restore the openclinica.data folder

Restoring the openclinica.data folder is quite simple--just copy the folder to your new installation location after deleting the current default folder. Below list the steps to accomplish this for Linux and Windows.

Linux

  • Issue the following command to go to the root folder of the openclinica.data directory "cd /usr/local/tomcat"
  • Issue "rm -rf openclinica.data" to remove the current default installations openclinica.data folder.
  • Issue "cp -rf $OPENCLINICA.DATAFOLDER BACKUP /usr/local/tomcat/" to restore your openclinica.data folder.
  • Next issue a "chown -R tomcat /usr/loca/tomcat/*". This ensures your permissions are setup correctly for OpenClinica to access the folder.

Your openclinica.data folder is now restored.

Windows

  • Open "My Computer" or "Explorer"
  • Navigate to "c:\oc\tomcat\"
  • Delete the current "openclinica.data" folder within "c:\oc\tomcat\"
  • Copy the openclinica.data folder you backed up to "c:\oc\tomcat\"

Your openclinica.data folder is now restored.

Current Community Contributed Content

http://en.wikibooks.org/wiki/OpenClinica_User_Manual/BackupAndRestore

Other Useful Links

http://www.postgresql.org/docs/8.4/static/backup.html

http://www.cyberciti.biz/tips/howto-backup-postgresql-databases.html

http://archives.postgresql.org/pgsql-admin/2001-03/msg00143.php

http://wiki.postgresql.org/wiki/Automated_Backup_on_Windows

http://www.wisdombay.com/articles/article000013.htm

Other Ideas or Suggestions

If you would like to submit any new configuration examples or troubleshooting tips based on your own experience, we would be more then happy to post them on this page. To submit new configurations or tips please post to the users email list with a Subject of "DOCS SITE:Backup and Restore" and we will add them to this page. Thanks!

 

This page is not approved for publication.