#!/bin/sh #----------------------------------------------------------------------------- # /var/install/bin/eisportal-tools-db-restore [filename] # # Creation: 03.07.2006 ys # Last Update: $Id$ # # Copyright (c) 2005-2006 Yves Schumann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #----------------------------------------------------------------------------- #include eislib . /var/install/include/eislib . /etc/config.d/eisportal mysql_data_dir=/var/lib/mysql mysql_base_dir=/usr/local/mysql #----------------------------------------------------------------------------- # use list-mysql.cui tool #----------------------------------------------------------------------------- # check if use cui version . /etc/config.d/setup if [ "$MENU" = "/var/install/bin/show-menu.cui" -a $# -lt 1 ] then /var/install/bin/list-files.cui -t "Restore EisPortal database" \ -c "Restore from:" \ -p ${EISPORTAL_DB_BACKUP_LOCATION} \ -f "eisportal_db?[0-9]*" \ -o 1 -d -n -w \ -s /var/install/bin/eisportal-tools-db-restore \ --helpfile=/var/install/help/eisportal \ --helpname=EISPORTAL_MENU_RESTORE \ --helpview exit 0 fi #----------------------------------------------------------------------------- # check for mysql #----------------------------------------------------------------------------- if [ ! -f /var/run/mysql.pid ] then mecho "" mecho -error "MySQL Server not running" mecho "" exit 1 fi # clear screen after mysql check clrhome if [ $# -lt 1 ] then #----------------------------------------------------------------------------- # ask for db file #----------------------------------------------------------------------------- mecho "" mecho -info "Restore EisPortal database" mecho "" mecho "Enter name of the dump file including the full path:" mecho "" sqlFileToRestore=`/var/install/bin/ask "> " "" "*"` mecho "" else sqlFileToRestore=$1 yesRestoreNow="yes" fi if [ -z "$sqlFileToRestore" ] then mecho -info "Nothing given to restore" mecho "" exit 1 fi #----------------------------------------------------------------------------- # ask once more #----------------------------------------------------------------------------- if [ -z "$yesRestoreNow" ] then mecho -warn "Really restore database?" mecho -warn -n "Any existing data in the database will be lost!" yesRestoreNow=`/var/install/bin/ask " " "n"` fi #----------------------------------------------------------------------------- # restore db now #----------------------------------------------------------------------------- if [ "$yesRestoreNow" == "yes" ] then mecho -n "Restoring database... " mysql_pass=`grep passwd= ${mysql_data_dir}/backup.pwd | sed "s/passwd=//g"` ${mysql_base_dir}/bin/mysql -h ${EISPORTAL_DB_HOST} -u ${EISPORTAL_DB_ADMIN_USER} -p${EISPORTAL_DB_ADMIN_PASS} ${EISPORTAL_DB_NAME} < ${sqlFileToRestore} mecho "Done" fi anykey exit 0 ### --------------------------------------------------------------------------- ### End ###----------------------------------------------------------------------------