::----------------------------------------------------------------------------- :: 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 :\p4\common\bin :: folder prior to running this script. :: :: Run :\p4\common\bin\p4env.bat before running this script. :: :: Then, just run this script. @echo off setlocal enableextensions if "%DEPOTDATA_ROOT%x" == "x" goto P4ENVERR set LOG=%LOGDATA_ROOT%\p4\%SDP_INSTANCE%\logs\upgrade.log p4 login < %DEPOTDATA_ROOT%\p4\common\bin\adminpass.txt >> %LOG% 2>&1 if NOT ERRORLEVEL 0 goto ERROR echo Get the journal counter >> %LOG% 2>&1 for /f "tokens=*" %%a in ( 'p4 counter journal' ) do ( set jnlnum=%%a ) echo Remove the trailing space from the journal counter >> %LOG% 2>&1 set /a jnlnum=%jnlnum% echo Set ckpnum to the journal counter value + 1 >> %LOG% 2>&1 set /a ckpnum=%jnlnum% + 1 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) svcinst stop -n %SDP_INSTANCE_P4SERVICE_NAME% >> %LOG% 2>&1 REM Wait for service to stop. :RETRY echo Waiting for service %SDP_INSTANCE_P4SERVICE_NAME% to stop... timeout /t 60 sc query %SDP_INSTANCE_P4SERVICE_NAME% | find /I "stopped" if not %ERRORLEVEL% == 0 goto RETRY echo Rotate the journal >> %LOG% 2>&1 %DEPOTDATA_ROOT%\p4\%SDP_INSTANCE%\bin\p4d -r %METADATA_ROOT%\p4\%SDP_INSTANCE%\root -J %LOGDATA_ROOT%\p4\%SDP_INSTANCE%\logs\journal -jj %DEPOTDATA_ROOT%\p4\%SDP_INSTANCE%\checkpoints\p4_%SDP_INSTANCE% >> %LOG% 2>&1 if NOT ERRORLEVEL 0 goto ERROR echo Replay the journal to the offline_db directory >> %LOG% 2>&1 %DEPOTDATA_ROOT%\p4\%SDP_INSTANCE%\bin\p4d -r %METADATA_ROOT%\p4\%SDP_INSTANCE%\offline_db -jr %DEPOTDATA_ROOT%\p4\%SDP_INSTANCE%\checkpoints\p4_%SDP_INSTANCE%.jnl.%jnlnum% >> %LOG% 2>&1 if NOT ERRORLEVEL 0 goto ERROR echo Copy in the new binaries >> %LOG% 2>&1 copy %DEPOTDATA_ROOT%\p4\common\bin\p4.exe %DEPOTDATA_ROOT%\p4\%SDP_INSTANCE%\bin >> %LOG% 2>&1 if NOT ERRORLEVEL 0 goto ERROR copy %DEPOTDATA_ROOT%\p4\common\bin\p4d.exe %DEPOTDATA_ROOT%\p4\%SDP_INSTANCE%\bin >> %LOG% 2>&1 if NOT ERRORLEVEL 0 goto ERROR copy %DEPOTDATA_ROOT%\p4\common\bin\p4d.exe %DEPOTDATA_ROOT%\p4\%SDP_INSTANCE%\bin\p4s.exe >> %LOG% 2>&1 if NOT ERRORLEVEL 0 goto ERROR echo Upgrade the server and restart it >> %LOG% 2>&1 %DEPOTDATA_ROOT%\p4\%SDP_INSTANCE%\bin\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 echo Upgrade the offline_db directory and dump out a new checkpoint file. >> %LOG% 2>&1 %DEPOTDATA_ROOT%\p4\%SDP_INSTANCE%\bin\p4d -r %METADATA_ROOT%\p4\%SDP_INSTANCE%\offline_db -J off -xu >> %LOG% 2>&1 if NOT ERRORLEVEL 0 goto ERROR %DEPOTDATA_ROOT%\p4\%SDP_INSTANCE%\bin\p4d -r %METADATA_ROOT%\p4\%SDP_INSTANCE%\offline_db -jd -z %DEPOTDATA_ROOT%\p4\%SDP_INSTANCE%\checkpoints\p4_%SDP_INSTANCE%.ckp.%ckpnum%.gz >> %LOG% 2>&1 if NOT ERRORLEVEL 0 goto ERROR goto END :ERROR echo An ERROR occured in the upgrade process, please check %LOG% for the errors. goto END :P4ENVERR echo "You must run \p4\common\bin\p4env.bat before running this script." :END endlocal