#!/bin/sh #---------------------------------------------------------------------------- # /var/install/bin/mysql-common-tools-resrore - MariaDB/MySQL Server restore # # Creation: 2004-06-22 jv # Last Update: $Id$ # # Copyright (c) 2004 Jens Vehlhaber, jvehlhaber(at)buchenwald(dot)de # Copyright (c) 2012-@@YEAR@@ Holger Bruenjes, holgerbruenjes(at)gmx(dot)net # # 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 # --------------------------------------------------------------------------- # defaults # --------------------------------------------------------------------------- get_defaults() { # default values . /srv/mysql/defaults.info eval backup_dir='${'${project_name}'_BACKUP_TARGET}' mysql_backupdir="${backup_dir:-/var/lib/mysql_backup}" } # --------------------------------------------------------------------------- # check mount # --------------------------------------------------------------------------- check_mount() { eval backup_mount='${'${project_name}'_BACKUP_MOUNT}' if [ -n "${backup_mount}" ] then eval '${'${project_name}'_BACKUP_MOUNT}' fi } # --------------------------------------------------------------------------- # check umount # --------------------------------------------------------------------------- check_umount() { eval backup_umount='${'${project_name}'_BACKUP_UMOUNT}' if [ -n "${backup_umount}" ] then eval '${'${project_name}'_BACKUP_UMOUNT}' fi } # --------------------------------------------------------------------------- # check status and access of MariaDB/MySQL Database # --------------------------------------------------------------------------- check_status() { if [ ! -f ${mysql_pid_file} ] then echo mecho --error 'MariaDB/MySQL Server is not running.' echo exit 1 fi ${mysql_basedir}/${db_mysqladmin} --socket=${mysql_socket} \ status >/dev/null 2>&1 if [ ${?} -ne 0 ] then echo mecho -n --error 'MariaDB/MySQL Server' mecho -n --std " 'root' " mecho --error 'password is required.' mecho --info 'Please set the root password.' echo exit 1 fi } # --------------------------------------------------------------------------- # select file and make restore # --------------------------------------------------------------------------- run_list() { color='' if $(grep -qE "^MENU=['\"]/var/install/bin/show-menu['\"]" /etc/config.d/setup) then color='--nocolor' fi /var/install/bin/list-files.cui -t "Select SQL file" \ -c "Restore from:" ${color} \ -p ${mysql_backupdir} \ -f "*[0-2][0-9][0-9][0-9]*-[0-5][0-9].???*" \ -o 1 -d -n -w \ -s "/usr/bin/mysql-common-restore.sh --project ${package_name}" \ --helpfile=/var/install/help/${package_name} \ --helpname=${project_name}_MENU_RESTORE } # --------------------------------------------------------------------------- # main # --------------------------------------------------------------------------- main() { package_name="${1}" project_name=$(echo ${package_name} | tr [:lower:] [:upper:]) my_path=$(echo "${package_name}" | sed 's|[^[:digit:]]||g') # read the config parameter . /etc/config.d/${package_name} get_defaults check_status check_mount run_list check_umount exit 0 } # --------------------------------------------------------------------------- # call function main # --------------------------------------------------------------------------- main "${@}" # --------------------------------------------------------------------------- # end # ---------------------------------------------------------------------------