Server Management - Systems Insight Manager
cancel
Showing results for 
Search instead for 
Did you mean: 

Backup Script for HPSIM on linux

T.James
Occasional Contributor

Backup Script for HPSIM on linux

I wrote a short backup script for my linux installation of HP SIM.  

 

Either copy and paste the following or grab the file below.

 

Feel free to use/modify this for your own purposes.

 

# Created by: Tim James - tajames@niu.edu
# Creation date: 8/20/2011


# Simple script to backup the whole lot of HP SIM
# Create a temp directory with all the config file locations already propagated
# Copy all of the existing config files into the temp location
# Dump the postgres DB into the temp location
# tar that beast and call it the current date

# NOTE: this makes use of a .pgpass file in the home directory of the user
# that is going to run the script.

 

dir_loc=/backup/SIM_Bkup
bkup_loc=/backup
bkup_date=`date +"%Y%m%d"`
bkup_day=`date +"%A"`

 

# Only save 7 days worth of backups.

if [ "$bkup_day" == "Sunday" ]; then
rm /backup/*
fi

 

# Create temp locations for files.

mkdir -p $dir_loc/etc/opt/mx/config/
mkdir -p $dir_loc/var/opt/mx/config/
mkdir -p $dir_loc/etc/opt/hp/sslshare/
mkdir -p $dir_loc/var/opt/mx/logs/
mkdir -p $dir_loc/opt/mx/bin/
mkdir -p $dir_loc/opt/mx/patch/
mkdir -p $dir_loc/var/opt/mx/output/

 

cp -R /etc/opt/mx/config $dir_loc/etc/opt/mx/config
cp -R /var/opt/mx/config/ $dir_loc/var/opt/mx/config/
cp -R /etc/opt/hp/sslshare/ $dir_loc/etc/opt/hp/sslshare/
cp /var/opt/mx/logs/mx.log $dir_loc/var/opt/mx/logs/
cp -R /opt/mx/patch/ $dir_loc/opt/mx/patch/
cp /opt/mx/bin/server_cert.pem $dir_loc/opt/mx/bin/
cp /opt/mx/bin/CLIClientConfig.cfg $dir_loc/opt/mx/bin/
cp -R /var/opt/mx/output $dir_loc/var/opt/mx/output/

 

# PG-DUMP to get the file into a format able to be backed-up

/opt/hpsmdb/bin/pg_dump -h 127.0.0.1 -p 50006 -U mxadmin insight_v1_0 > $dir_loc/saveHPSIMdb

 

# TAR that meagerie of stuff

tar -zcf $bkup_loc/$bkup_date.tar.gz $dir_loc

 

# Cleanup the temp files created.
rm -r $dir_loc/