The Backup process

This page contains data on how to backup and restore the Shared Health Record using a script which creates backup files of the SHR database and the App Data folder, and copies them into an external server / machine specified by the user.

This process is only valid for linux SHR server machines, and not windows.

Backup steps,

The purpose of this file is to create a backup of the OpenMRS database and the AppData folder, and move it to an external server.

The contents of the file would be as follows –

# Dump the data from OpenMRS to a file

mysqldump -u root --password=test openmrs > /home/ubuntu/openmrs_bkup.sql

# Copy the AppData folder into /home/ubuntu

cp -rf /usr/share/tomcat6/.OpenMRS /home/ubuntu/

# Zip up the backup files

zip -r openmrs_`date +%y%m%d` openmrs_bkup.sql .OpenMRS

#Display new file

echo "created backup file : " openmrs_`date +%y%m%d`

#send the file into the remote server

scp openmrs_`date +%d%m%y` username@host:.

 

Make the following changes to this script

Configuring the backup machine

Create a new cronjob on the linux server

A sample command to execute the script file every five minutes would be –

*/5 * * * * /home/ubuntu/backupScript.sh > /home/ubuntu/backup.log 2>&1

Here, the log output created by the commands (success or failure messages / output of echo messages ion the script file) are written into the backup.log file.

One the cronjob is triggered, the backup files will be created and copied into the remote server specified in the script file.


Notes :

In order to run the same script multiple times on the same machine, we will need to clean up the previous backup files (zip + sql) so that fresh copies can be created.

The current backup script assumes that the machine the backup files are being copied into has not enforced any special security restrictions. However, tighter security restrictions may make it nessesary to modify the script file to match these needs.

Remote vs. local backup


 Considering the importance of the data, backups files should be physically moved to remote locations at least once a week.

Recovery procedures


 
In the event of a failure, we can restore the system using the backup files. This process can be broken down into the following steps, 

Monitoring the backup process

 

Currently, the backup process occurs once daily, and the resulting tar file is stored in the same server. These backups are not currently transferred into an external server. 

Therefore, the only way to monitor if the backups are successful is to do so manually by unzipping a backup file and checking if it contains all required files.