Backups
An essential task in maintaining an instance of OpenEMPI is performing backups of the instance, which includes making backups of the data in the database as well as backups of the software itself. Although you could easily reconstruct your instance by simply creating backups of the configuration files of your instance instead of all the software that comprise the instance, it is faster to bring the instance back using a complete backup of the software.
Backups of the Postgres Database Instance
The following script can be used as a sample for making backups of both the data in the database and of the software. Feel free to customize it to match the particulars of your installation.
#!/bin/bash app_name=openempi backup_dir=/home/openempi/backups backup_filename=$app_name-backup-`date +%Y-%m-%d` backup_filename_tar="$backup_filename".tar.gz openempi_home=/sysnet/openempi openempi_filename_tar=openempi.tar # Print status echo "Backing up $appname..." echo "Archiving Client Registry Software" cd $openempi_home tar cf $backup_dir/$openempi_filename_tar . cd $backup_dir # Backup all the things - config files and databases #--------------------------------------------------- # Backup the Postgress database db_user="openempi" db_password="openempi" db_name="openempi" backup_filename_sql=$backup_filename".sql" export PGPASSWORD=$db_password echo "Backing up the Database Instance for OpenEMPI into $backup_filename_sql" /usr/bin/pg_dump --username=$db_user -w --host=localhost $db_name > $backup_filename_sql # Archive all the things #----------------------- echo "Archiving the dabatase backup and OpenEMPI softare distribution" cd $backup_dir tar czf $backup_filename_tar $backup_filename_sql $openempi_filename_tar # Cleanup #-------- # Clean up file that aren't needed here... echo "Cleaning up backup file in $backup_dir/$backup_filename_sql" rm $backup_dir/$backup_filename_sql $backup_dir/$openempi_filename_tar # Finalise # Print status echo "Done backing up $app_name." # Display created backup file echo "Created backup file: " $backup_filename_tar " in " $backup_dir # Copy to off site server remote_user="username" remote_pass="password" remote_host="www.openempi.org" remote_dir="/home/openempi" # scp $backup_dir/$backup_filename_tar $remote_user@$remote_host:$remote_dir echo "Copied backup file to remote server: " $backup_filename_tar # Cleanup old backup files # - keep previous 30 days backups and the backup from the first of every month find $backup_dir -name "$app_name-backup-*" -mtime +10 -not -name "$app_name-backup*-01.tar.gz" -exec rm {} \;
Backups of the Graph Database
The simplest way to backup the embedded graph database that OpenEMPI uses to store the core data that is managed by the system is by performing a backup of the filesystem data that includes the database files. The location where the database files are stored is specified using the data-directory parameter in the mpi-config.xml file. Make sure you shutdown the OpenEMPI server before performing a backup to ensure that the data does not change while the backup operation is taking place.
Restoring an Instance
In this section we describe the steps involved in restoring an instance of OpenEMPI from a backup file. The assumption is that you have a previous backup of your running instance that was created the backup script in the previous section. The backup includes both the software that comprise a running instance of OpenEMPI and the data in the database. The other assumption that we are making here is that you are installing an instance of OpenEMPI on a new server which is missing the COTS software that are used to support a running instance of OpenEMPI and all you have is the latest backup file.
- Install the Postgres database software: This is described in detail here
- Install the JBoss application server: This is described in detail /wiki/spaces/openempi30/pages/295102
- Extract the backup: From the OpenEMPI home directory, extract the backup using the command: tar xvfz backup-file.tar.gz. There should now be two more files in your directory, one with an extension (.sql) that comprises the database backup and one with an extension (.tar) which comprises the OpenEMPI software.
- Restore the data in the database: To achieve this step, use the psql command to connect to your Postgres instance and then load the data from the backup file.
$ psql --user=openempi --host=localhost openempi Password for user openempi: psql (9.1.5) SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256) Type "help" for help. openempi=# \i openempi-backup-2013-01-01.sql openempi=# \q
- Restore the OpenEMPI software installation. To achieve this step, you simply need to move to the OpenEMPI home directory and extract the backup file.
$ cd $OPENEMPI_HOME $ tar xvfz ${LOCATION_OF_BACKUP_FILE}/openempi.tar
- Check the openempi_env.sh file to make sure that the OPENEMPI_HOME variable points to the correct location of the home directory for the OpenEMPI software. If you restored the software in a different location from its original one, you will need to make this change.