How to restore OpenSpecimen from older backup?

Please note that while restoring the database you also need to restore the os-data directory. The state of the app is not just database, it is a combination of (database + data directory i.e. os-data directory). So both need to be restored to the same date.

Please follow the below steps to restore OpenSpecimen data from the backup:

MySQL:

  • Stop the OpenSpecimen service.
  • Connect to MySQL using root as mysql -uroot -p[xxxx].
  • Create a database with a new name using create database [new_os].
  • Assign proper privileges to the openspecimen user to connect to this new database.
  • Open command prompt/terminal.
  • Restore the backup using mysql -u [openspecimen] -p[xxxx] [new_os] < [older_back_file_name.sql].
  • Restore the os-data folder to the same date as of the database backup.
  • Update the new database name in tomcat/conf/context.xml.
  • Start the OpenSpecimen service.
  • Once everything is fine, please update the backup script to point to the newly created database.

Oracle:

  • Stop the OpenSpecimen service.
  • Connect to Oracle using sqlplus / as sysdba.
  • Create a user with a new name using create user [new_os] identified by [new password].
  • Grant proper privileges to the newly created user [new_os] to connect to this new database.
  • Open command prompt/terminal
  • Restore the backup using impdp <username>/<password> DIRECTORY=<DUMP_DIR> DUMPFILE=<older_back_file_name.sql> REMAP_SCHEMA=<from_user>:<to_user> logfile=<logfile.log> transform=oid:n
  • Restore the os-data folder to the same date as of the database backup.
  • Update the new database name in tomcat/conf/context.xml.
  • Start the OpenSpecimen service.
  • Once everything is fine, please update the backup script to point to the newly created database.