#!/bin/bash # Check our arguments while getopts ":DF:m:p:P:s:u:" opt; do case $opt in D) DEBUG=1 ;; # Filespace to store in TSM F) FILESPACE=$OPTARG ;; # Optional MYSQL arguments m) MYSQL_ARGS=$OPTARG ;; # Mysql PASSWORD p) DBPASS=$OPTARG ;; # PITDATE to restore P) PITDATE=$OPTARG ;; # Skip DBs s) SKIP_DB=$OPTARG ;; # Mysql USERNAME u) DBUSER=$OPTARG ;; # Error Checking \?) echo "Invalid option: -$OPTARG" >&2 exit 1 ;; :) echo "Option -$OPTARG requires an argument." >&2 exit 1 ;; esac done # Our defaults DB=${@:?"You need to specicify a database to restore"} FILESPACE=${FILESPACE:-"/mysqldump"} [ -n "$DBPASS" ] && MYSQL_AUTH="-p${DBPASS}" [ -n "$DBUSER" ] && MYSQL_AUTH="-u${DBUSER} ${MYSQL_AUTH}" # TSMPIPE ARGUMENTS [ -n "$PITDATE" ] && TSMPIPE_ARGS="${TSMPIPE_ARGS} -P ${PITDATE}" OLDIFS=$IFS IFS=":" for db in $DB; do [ -n "$DEBUG" ] && echo "Processing DB ($db)" # Restore from TSM tsmpipe -Bxs ${FILESPACE} -f ${db}.FULL ${TSMPIPE_ARGS} | mysql ${MYSQL_AUTH} ${db} done; IFS=$OLDIFS