::----------------------------------------------------------------------------- :: Copyright (c) Perforce Software, Inc., 2007-2014. All rights reserved :: :: Redistribution and use in source and binary forms, with or without :: modification, are permitted provided that the following conditions are met: :: :: 1 Redistributions of source code must retain the above copyright :: notice, this list of conditions and the following disclaimer. :: :: 2. Redistributions in binary form must reproduce the above copyright :: notice, this list of conditions and the following disclaimer in the :: documentation and/or other materials provided with the distribution. :: :: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS :: "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT :: LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS :: FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PERFORCE :: SOFTWARE, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, :: SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT :: LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, :: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON :: ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR :: TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF :: THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH :: DAMAGE. ::----------------------------------------------------------------------------- :: Place the new p4.exe and p4d.exe binaries into the c:\p4\common\bin :: folder prior to running this script. :: :: Run this script with a single parameter which is the instance. @echo off setlocal enableextensions set current_script_dir=%~p0 call %current_script_dir%p4env.bat %1 if errorlevel 1 ( echo Upgrade aborted - invalid config file found. echo . exit /B 1 ) if x%SDP_INSTANCE% == x ( echo Upgrade aborted - no instance parameter specified. echo . exit /B 1 ) if not exist %current_script_dir%p4d.exe ( echo Can't find new P4D: %current_script_dir%p4d.exe echo . exit /b 1 ) if not exist %current_script_dir%p4.exe ( echo Can't find new P4: %current_script_dir%p4.exe echo . exit /b 1 ) set LOG=%LOGS_DIR%\upgrade.log echo Starting upgrade.>> %LOG% :: Check if we are in admin mode - things won't work otherwise - can't stop the service. net session >:NULL 2>&1 IF not %ERRORLEVEL% EQU 0 ( ECHO You must run upgrade.bat with Administrator privileges.>> %LOG% ECHO You must run upgrade.bat with Administrator privileges. goto ERROR ) echo Determining current journal counter.>> %LOG% echo Determining current journal counter. :: Dump just the db.counters table to stdout and parse for the counter for /F "tokens=5" %%F in ('"%SDP_INSTANCE_BIN_DIR%\p4d -r %P4ROOT% -jd - db.counters | findstr @journal@"') do (set JNL=%%F) if %JNL%x == x ( echo ERROR:>> %LOG% echo ERROR: Could not determine journal counter; JNL not set!>> %LOG% echo ERROR: Could not determine journal counter; JNL not set! echo ERROR:>> %LOG% goto ERROR ) :: Turn "@123@" to "123" set JNL=%JNL:~1,-1% set /A CKP=JNL+1 if %CKP%x == x ( echo ERROR:>> %LOG% echo ERROR: Could not determine next checkpoint number; CKP not set!>> %LOG% echo ERROR: Could not determine next checkpoint number; CKP not set! echo ERROR:>> %LOG% goto ERROR ) echo Live checkpoint/journal numbers are %CKP%/%JNL%.>> %LOG% echo Live checkpoint/journal numbers are %CKP%/%JNL%. :: Find out the current journal counter for our offline database :: Dump just the db.counters table to stdout and parse for the counter for /F "tokens=5" %%F in ('"%SDP_INSTANCE_BIN_DIR%\p4d -r %OFFLINE_DB_DIR% -jd - db.counters | findstr @journal@"') do (set OFF_JNL=%%F) if %OFF_JNL%x == x ( echo ERROR:>>%LOG% echo ERROR: Could not determine offline journal counter; OFF_JNL not set!>>%LOG% echo ERROR: Could not determine offline journal counter; OFF_JNL not set! echo ERROR:>>%LOG% goto ERROR ) :: Turn "@123@" to "123" set OFF_JNL=%OFF_JNL:~1,-1% call :OUTPUT_TIME echo Offline journal number is %OFF_JNL%.>> %LOG% echo Offline journal number is %OFF_JNL%. sc queryex %SDP_INSTANCE_P4SERVICE_NAME% | find /I "PID" > pid.txt for /F "tokens=1,2 delims=: " %%i in (pid.txt) DO (set P4SPID=%%j) echo Stopping the live service echo svcinst stop -n %SDP_INSTANCE_P4SERVICE_NAME% svcinst stop -n %SDP_INSTANCE_P4SERVICE_NAME% >> %LOG% 2>&1 REM Check service has stopped sc query %SDP_INSTANCE_P4SERVICE_NAME% | find /I "stopped" if not %ERRORLEVEL% == 0 goto ERROR call :OUTPUT_TIME echo Cutting off/rotating current journal>> %LOG% echo Cutting off/rotating current journal echo %SDP_INSTANCE_BIN_DIR%\p4d -r %P4ROOT% -jj %CHECKPOINTS_DIR%\%SDP_INSTANCE_P4SERVICE_NAME%>> %LOG% echo %SDP_INSTANCE_BIN_DIR%\p4d -r %P4ROOT% -jj %CHECKPOINTS_DIR%\%SDP_INSTANCE_P4SERVICE_NAME% %SDP_INSTANCE_BIN_DIR%\p4d -r %P4ROOT% -jj %CHECKPOINTS_DIR%\%SDP_INSTANCE_P4SERVICE_NAME% >> %LOG% 2>&1 if NOT ERRORLEVEL 0 goto ERROR call :OUTPUT_TIME echo Applying all outstanding journal files to offline_db>> %LOG% echo Applying all outstanding journal files to offline_db echo .>> %LOG% for /L %%J in (%OFF_JNL%,1,%JNL%) do ( echo %SDP_INSTANCE_BIN_DIR%\p4d -r %OFFLINE_DB_DIR% -jr %CHECKPOINTS_DIR%\%SDP_INSTANCE_P4SERVICE_NAME%.jnl.%%J>> %LOG% echo %SDP_INSTANCE_BIN_DIR%\p4d -r %OFFLINE_DB_DIR% -jr %CHECKPOINTS_DIR%\%SDP_INSTANCE_P4SERVICE_NAME%.jnl.%%J %SDP_INSTANCE_BIN_DIR%\p4d -r %OFFLINE_DB_DIR% -jr %CHECKPOINTS_DIR%\%SDP_INSTANCE_P4SERVICE_NAME%.jnl.%%J >> %LOG% 2>&1 if NOT ERRORLEVEL 0 goto ERROR call :OUTPUT_TIME ) echo Copy in the new binaries >> %LOG% 2>&1 echo Copy in the new binaries echo copy %SCRIPTS_DIR%\p4.exe %SDP_INSTANCE_BIN_DIR% copy %SCRIPTS_DIR%\p4.exe %SDP_INSTANCE_BIN_DIR% >> %LOG% 2>&1 if NOT ERRORLEVEL 0 goto ERROR echo copy %SCRIPTS_DIR%\p4d.exe %SDP_INSTANCE_BIN_DIR% copy %SCRIPTS_DIR%\p4d.exe %SDP_INSTANCE_BIN_DIR% >> %LOG% 2>&1 if NOT ERRORLEVEL 0 goto ERROR echo copy %SCRIPTS_DIR%\p4d.exe %SDP_INSTANCE_BIN_DIR%\p4s.exe copy %SCRIPTS_DIR%\p4d.exe %SDP_INSTANCE_BIN_DIR%\p4s.exe >> %LOG% 2>&1 if NOT ERRORLEVEL 0 goto ERROR call :OUTPUT_TIME echo Upgrade the server and restart it >> %LOG% 2>&1 echo Upgrade the server and restart it echo %SDP_INSTANCE_BIN_DIR%\p4d -r %METADATA_ROOT%\p4\%SDP_INSTANCE%\root -J off -xu %SDP_INSTANCE_BIN_DIR%\p4d -r %METADATA_ROOT%\p4\%SDP_INSTANCE%\root -J off -xu >> %LOG% 2>&1 if NOT ERRORLEVEL 0 goto ERROR net start p4_%SDP_INSTANCE% if NOT ERRORLEVEL 0 goto ERROR call :OUTPUT_TIME echo Upgrade the offline_db directory and dump out a new checkpoint file. >> %LOG% 2>&1 echo Upgrade the offline_db directory and dump out a new checkpoint file. echo %SDP_INSTANCE_BIN_DIR%\p4d -r %OFFLINE_DB_DIR% -J off -xu %SDP_INSTANCE_BIN_DIR%\p4d -r %OFFLINE_DB_DIR% -J off -xu >> %LOG% 2>&1 if NOT ERRORLEVEL 0 goto ERROR call :OUTPUT_TIME echo %SDP_INSTANCE_BIN_DIR%\p4d -r %OFFLINE_DB_DIR% -jd -z %CHECKPOINTS_DIR%\%SDP_INSTANCE_P4SERVICE_NAME%.ckp.%ckp%.gz %SDP_INSTANCE_BIN_DIR%\p4d -r %OFFLINE_DB_DIR% -jd -z %CHECKPOINTS_DIR%\%SDP_INSTANCE_P4SERVICE_NAME%.ckp.%ckp%.gz >> %LOG% 2>&1 if NOT ERRORLEVEL 0 goto ERROR call :OUTPUT_TIME echo Finished!>> %LOG% echo Finished! echo Upgrade was successful - see %LOG% goto END :ERROR echo An ERROR occured in the upgrade process, please check for errors in %LOG% goto END :OUTPUT_TIME wmic os get LocalDateTime>> %LOG% wmic os get LocalDateTime goto :EOF :END endlocal
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#10 | 22919 | Robert Cowham |
Refacto sdp-functions Convert upgrade.bat into upgrade.ps1 Fix issue with p4verify.ps1 |
||
#9 | 19406 | Russell C. Jackson (Rusty) | Add -t localhost:1666 to offline_db upgrade to avoid license check in 2016.1 | ||
#8 | 16029 | C. Thomas Tyler |
Routine merge to dev from main using: p4 merge -b perforce_software-sdp-dev |
||
#7 | 15701 | C. Thomas Tyler | Routine merge down using 'p4 merge -b perforce_software-sdp-dev'. | ||
#6 | 11463 | Russell C. Jackson (Rusty) | Updated dev to prepare for Summit agreed changes. | ||
#5 | 11009 | Robert Cowham | Refactored the obtaining of journal counters. | ||
#4 | 11008 | Robert Cowham | Refactored - improved logging. | ||
#3 | 11007 | Robert Cowham | Tidy up output of upgrade. | ||
#2 | 11001 | Robert Cowham | Revamp of upgrade script - still needs a bit of work. | ||
#1 | 10961 | C. Thomas Tyler | Merge down from main. | ||
//guest/perforce_software/sdp/main/Server/Windows/p4/common/bin/upgrade.bat | |||||
#1 | 10872 | C. Thomas Tyler |
Added Windows SDP into The Workshop: * Combined (back) into Unix SDP structure. * Avoided adding duplicate files p4verify.pl, p4review.(py,cfg). * Upgraded 'dist.sh' utility to produce both Unix and Windows packages (*.tgz and *.zip), adjusting line endings on text files to be appropriate for Windows prior to packaging. To Do: * Resolve duplication of [template_]configure_new_server.bat. * Merge test suites for Windows and Unix into a cohesive set. |