@ECHO OFF SETLOCAL REM *** Job Run Variables: (Modify as required, see notes below) SET jobname=ARCHIVE SET appname=%2 SET dbname=%3 SET fakerun= ECHO Filename: ARCHIVE.BAT ECHO Date: Jan 18, 1998 (Initial QC) ECHO Created by: Douglas Bliss, Pinnacle Solutions, Inc. ECHO Comments: Create archive of parameter specified database ECHO (Process uses BeginArchive/EndArchive approach) ECHO. ECHO Usage: ARCHIVE type appname dbname ECHO Where: ECHO type = any dos name for archive (i.e. PRELOAD) ECHO appname = Essbase application name ECHO dbname = Essbase database name ECHO. ECHO Output: Copies all files to %%bkpath%%\\ directory REM *** Set fakerun= to prevent processing, it will REM merely create the esscmd and calc scripts. REM (it will skip esscmd execution) REM ***************************************************** SANITY CHECKS IF DEFINED dbname GOTO DoIt ECHO. ECHO Error! This batch file requires three parameters as follows: ECHO Parm 1: Backup type (i.e. Daily) ECHO Parm 2: Application (i.e. CCM) ECHO Parm 3: Database (i.e. CCM) ECHO. ECHO (Press any key to exit) PAUSE >NUL GOTO FIN :DoIt REM ***************************************************** INITIALIZATION PHASE ECHO. ECHO Beginning %jobname% Initialization Phase ECHO.|Time|Find /i "is" REM *** Working paths: SET apppath=%arborpath%\APP\%appname% SET pagepath=E:\ESSBASE\APP\%appname% SET util=%arborpath%\UTILITY SET bkpath=F:\backup SET destpath=%bkpath%\%appname%\%dbname%\%1 REM *** Generated output files: (kept or rebuilt each run) SET errfile=%util%\%jobname%.ERR SET outfile=%util%\Output\%jobname%.OUT SET hstfile=%util%\History\%jobname%.HST SET restore=%destpath%\Restore.bat REM *** Working/temporary files: (deleted at end of job) SET scrfile1=%util%\Archive1.SCR SET scrfile2=%util%\Archive2.SCR REM *** Essbase login info: (shhh...) SET svr=LocalHost SET uid=Archive SET pwd=GMBackup :DoItAlready REM *** Archive/delete job files in util directory: (must be done first) if exist %bkpath%\jobfiles\%jobname%*.* del %bkpath%\jobfiles\%jobname%*.* >nul if exist %util%\%jobname%*.* copy %util%\%jobname%*.* %bkpath%\jobfiles >nul if exist %util%\%jobname%*.* del %util%\%jobname%*.* REM *** Create starting entries in Output file: ECHO ============ Initializing %jobname% =========== > %outfile% ECHO Performing %1 Archive for %appname%:%dbname% >> %outfile% ECHO.|date|find /i "is" >> %outfile% ECHO.|time|find /i "is" >> %outfile% TYPE %outfile% >> %hstfile% ECHO =============== Before %jobname% =============== >> %outfile% IF EXIST %apppath%\%dbname%\%dbname%.* dir %apppath%\%dbname%\%dbname%.* >> %outfile% IF EXIST %pagepath%\%dbname%\ess*.* dir %pagepath%\%dbname%\ess*.* >> %outfile% REM ***************************************************** PREPARATION PHASE ECHO. ECHO Beginning %jobname% Preparation Phase (Batch/EssCmd Scripts) ECHO.|time|find /i "is" REM *** Create application backup directories if required: IF NOT EXIST %bkpath%\. MKDIR %bkpath% IF NOT EXIST %bkpath%\%appname%\. MKDIR %bkpath%\%appname% IF NOT EXIST %bkpath%\%appname%\%dbname%\. MKDIR %bkpath%\%appname%\%dbname% IF NOT EXIST %destpath%\. MKDIR %destpath% IF NOT EXIST %destpath%\objects\. MKDIR %destpath%\objects REM *** Generate temporary EssCmd script for initiating the backup: ECHO login "%svr%" "%uid%" "%pwd%" "" ""; > %scrfile1% ECHO output 2 "%errfile%"; >> %scrfile1% ECHO beginarchive "%appname%" "%dbname%" "%destpath%\filelist.txt"; >> %scrfile1% ECHO logout; >> %scrfile1% ECHO. >> %scrfile1% REM *** Generate temporary EssCmd script for concluding the backup: ECHO login "%svr%" "%uid%" "%pwd%" "" ""; > %scrfile2% ECHO output 2 "%errfile%"; >> %scrfile2% ECHO endarchive "%appname%" "%dbname%"; >> %scrfile2% ECHO select "%appname%" "%dbname%"; >> %scrfile2% ECHO getdbstats >> %scrfile2% ECHO logout; >> %scrfile2% ECHO. >> %scrfile2% REM *** Generate EssCmd script to unload database prior to restore: SET scrfile=%destpath%\unload.scr ECHO login "localhost" "%uid%" "%pwd%" "" ""; > %scrfile% ECHO unloadapp "%appname%"; >> %scrfile% ECHO logout; >> %scrfile% REM *** Generate EssCmd script to load database after restore: SET scrfile=%destpath%\load.scr ECHO login "%svr%" "%uid%" "%pwd%" "" ""; > %scrfile% ECHO loadapp "%appname%"; >> %scrfile% ECHO logout; >> %scrfile% REM ***************************************************** MAIN PROCESSING PHASE ECHO. ECHO Beginning %jobname% Main Processing Phase (from working directory) ECHO.|time|find /i "is" ECHO ============ Starting %jobname% =========== >> %outfile% ECHO.|time|find /i "is" >> %outfile% IF DEFINED fakerun GOTO SkipIt esscmd %scrfile1% >> %outfile% REM *** Create a special backup of the security file copy %arborpath%\bin\essbase.sec %destpath% REM *** Copy specified files to the backup directory FOR /F %%a IN (%destpath%\filelist.txt) DO copy %%~fa %destpath% >nul REM *** Make a backup of all essbase objects: if exist %destpath%\objects\*.* del /f /q %destpath%\objects\*.* copy %apppath%\%dbname%\%dbname%.otl %destpath%\objects copy %apppath%\%dbname%\*.rul %destpath%\objects copy %apppath%\%dbname%\*.csc %destpath%\objects copy %apppath%\%dbname%\*.rep %destpath%\objects esscmd %scrfile2% >> %outfile% REM *** Generate batch file for restoring the archive: ECHO @ECHO OFF > %restore% ECHO ECHO *** This file is automatically generated -- DO NOT MODIFY! >> %restore% ECHO ECHO. >> %restore% ECHO ECHO Filename RESTORE.BAT >> %restore% ECHO ECHO Comments: Restores archive of %appname%:%dbname% database >> %restore% ECHO ECHO (Archive made with BeginArchive/EndArchive approach) >> %restore% ECHO. >> %restore% ECHO esscmd %destpath%\unload.scr >> %restore% ECHO Del %apppath%\%dbname%\%dbname%.* >> %restore% FOR /F %%a IN (%destpath%\filelist.txt) DO ECHO copy %destpath%\%%~nxa %%~fa >> %restore% ECHO esscmd %destpath%\load.scr >> %restore% ECHO copy %destpath%\objects\*.* %apppath%\%dbname% >> %restore% ECHO. >> %restore% :SkipIt REM ***************************************************** CLEAN UP PHASE ECHO. ECHO Beginning %jobname% Clean-up Phase ECHO.|time|find /i "is" ECHO ============= Completing %jobname% ============= >> %outfile% ECHO Archive of %appname%:%dbname% completed >> %outfile% ECHO.|time|find /i "is" >> %outfile% ECHO. >> %outfile% ECHO ============== After %jobname% ============= >> %outfile% IF EXIST %destpath%\*.* dir %destpath%\*.* >> %outfile% IF EXIST %destpath%\objects\*.* dir %destpath%\objects\*.* >> %outfile% ECHO. >> %outfile% REM *** Delete working files: IF DEFINED fakerun GOTO NoDelete IF EXIST %scrfile1% DEL %scrfile1% IF EXIST %scrfile2% DEL %scrfile2% :NoDelete TYPE %outfile% | find /i "sts =" >> %hstfile% TYPE %errfile% | find /i "error" >> %hstfile% ECHO Completing Archive operations in %appname%:%dbname% >> %hstfile% ECHO.|time|find /i "is" >> %hstfile% ECHO. >> %hstfile% :FIN ENDLOCAL REM ***************************************************** END