Добро пожаловать, Гость
Логин: Пароль: Запомнить меня

ТЕМА: Скрипт для восстановления базы frontol из архива

Скрипт для восстановления базы frontol из архива 8 года 11 мес. назад #232

  • admin
  • admin аватар
  • Вне сайта
  • Администратор
  • Сообщений: 63
  • Спасибо получено: 2
  • Репутация: 1001
В новую папку кладем файл архивной копии, создаем и запускаем скрипт restore.cmd

начало
@echo off

rem Restore script for FireBird bases
rem Version 0.4 by theMIROn
echo Restore script for FireBird bases 0.4

rem This program is free software; you can redistribute it and/or
rem modify it under the terms of the GNU General Public License
rem as published by the Free Software Foundation; either version 2
rem of the License, or (at your option) any later version.
rem This program is distributed in the hope that it will be useful,
rem but WITHOUT ANY WARRANTY; without even the implied warranty of
rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
rem GNU General Public License for more details.
rem You should have received a copy of the GNU General Public License
rem along with this program; if not, write to the Free Software
rem Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

set fb_dir=%ProgramFiles%\FireBird\
set fb_user=sysdba
set fb_pass=masterkey
set gfix_name=gfix.exe
set gbak_name=gbak.exe
set dtbase_ext=GDB
set backup_ext=GBK
set dfixed_ext=TMP

echo Searching for FireBird utilites in %fb_dir%
for /r "%fb_dir%" %%I in (%gfix_name%) do if exist %%I set gfix=%%~I
for /r "%fb_dir%" %%I in (%gbak_name%) do if exist %%I set gbak=%%~I
if "%gfix%"=="" echo Error: %gfix_name% not found
if "%gbak%"=="" echo Error: %gbak_name% not found
if "%gfix%"=="" goto :eof
if "%gfix%"=="" goto :eof

echo Searching for base backups in %~dp0
for %%I in (*.%backup_ext%) do call :restore %%~dpnI
echo Restore finished.
goto :eof

:restore
set src=%1.%dtbase_ext%
set bak=%1.%backup_ext%
set dst=%1.%dfixed_ext%

echo Restore %bak%...

if not exist %dst% goto step1
del %dst%
if exist %dst% goto :eof

:step1
if not exist %src% goto step2
echo - shutting base
"%gfix%" -shut -force 0 %src% -user %fb_user% -pass %fb_pass%

:step2
echo - restoring to %dst%
"%gbak%" -r -rep %bak% %dst% -user %fb_user% -pass %fb_pass%

if not exist %src% goto step3
echo - connecting base
"%gfix%" -online %src% -user %fb_user% -pass %fb_pass%

:step3
if not exist %dst% goto :eof
echo - recreating %src%
copy %dst% %src%
del %dst%


конец
Администратор запретил публиковать записи гостям.

---