::----------------------------------------------------------------------------- :: 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 .> %LOG% call :REPORT Starting pre-2013.3 upgrade to post-2013.3. :: Check offline_db has some data if not exist %OFFLINE_DB_DIR%\db.counters ( call :REPORT The offline db files don't exist: %OFFLINE_DB_DIR% goto ERROR ) :: 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 ( call :REPORT You must run upgrade.bat with Administrator privileges. goto ERROR ) call :REPORT Upgrading perforce server - current version: call :EXECUTE %SDP_INSTANCE_BIN_DIR%\p4d -V %SDP_INSTANCE_BIN_DIR%\p4d -V call :REPORT to new version: call :EXECUTE p4d -V p4d -V call :REPORT Press any key to continue (or Ctrl+C to abort) pause call :REPORT Determining current journal counter. call :GET_JOURNAL_COUNTER %P4ROOT% set JNL=%_result% set /A CKP=JNL+1 if %CKP%x == x ( call :REPORT ERROR: echo :REPORT ERROR: Could not determine next checkpoint number; CKP not set! call :REPORT ERROR: goto ERROR ) call :REPORT Live checkpoint/journal numbers are %CKP%/%JNL%. :: Set to same as current as we will restore latest checkpoint set OFF_JNL=%JNL% call :OUTPUT_TIME call :REPORT Offline journal number is %OFF_JNL%. call :REPORT Recover latest checkpoint to offline_db using new p4d. call :EXECUTE del %OFFLINE_DB_DIR%\db.* call :EXECUTE %SCRIPTS_DIR%\p4d.exe -r %OFFLINE_DB_DIR% -jr -z %CHECKPOINTS_DIR%\%SDP_INSTANCE_P4SERVICE_NAME%.ckp.%jnl%.gz call :OUTPUT_TIME call :REPORT Upgrade the offline database. call :EXECUTE %SCRIPTS_DIR%\p4d.exe -r %OFFLINE_DB_DIR% -J off -xu call :OUTPUT_TIME call :REPORT Stopping the live service (can take up to 2 minutes) call :EXECUTE svcinst stop -n %SDP_INSTANCE_P4SERVICE_NAME% REM Check service has stopped sc query %SDP_INSTANCE_P4SERVICE_NAME% | find /I "stopped" if not %ERRORLEVEL% == 0 goto ERROR call :OUTPUT_TIME call :REPORT Cutting off/rotating current journal call :EXECUTE %SDP_INSTANCE_BIN_DIR%\p4d -r %P4ROOT% -jj %CHECKPOINTS_DIR%\%SDP_INSTANCE_P4SERVICE_NAME% if NOT ERRORLEVEL 0 goto ERROR call :OUTPUT_TIME call :REPORT Applying all outstanding journal files to offline_db for /L %%J in (%OFF_JNL%,1,%JNL%) do ( call :EXECUTE %SDP_INSTANCE_BIN_DIR%\p4d -r %OFFLINE_DB_DIR% -jr %CHECKPOINTS_DIR%\%SDP_INSTANCE_P4SERVICE_NAME%.jnl.%%J if NOT ERRORLEVEL 0 goto ERROR call :OUTPUT_TIME ) call :REPORT Copy in the new binaries call :EXECUTE copy %SCRIPTS_DIR%\p4.exe %SDP_INSTANCE_BIN_DIR% if NOT ERRORLEVEL 0 goto ERROR call :EXECUTE copy %SCRIPTS_DIR%\p4d.exe %SDP_INSTANCE_BIN_DIR% if NOT ERRORLEVEL 0 goto ERROR call :EXECUTE copy %SCRIPTS_DIR%\p4d.exe %SDP_INSTANCE_BIN_DIR%\p4s.exe if NOT ERRORLEVEL 0 goto ERROR call :OUTPUT_TIME echo Move recovered db files from offline_db to root >> %LOG% call :EXECUTE %P4ROOT%\save\db.* call :EXECUTE move %P4ROOT%\db.* %P4ROOT%\save call :EXECUTE move %OFFLINE_DB_DIR%\db.* %P4ROOT% call :OUTPUT_TIME call :EXECUTE net start p4_%SDP_INSTANCE% if NOT ERRORLEVEL 0 goto ERROR call :OUTPUT_TIME call :EXECUTE %SDP_INSTANCE_BIN_DIR%\p4d.exe -r %OFFLINE_DB_DIR% -jr -z %CHECKPOINTS_DIR%\%SDP_INSTANCE_P4SERVICE_NAME%.ckp.%jnl%.gz call :OUTPUT_TIME call :REPORT Upgrade the offline database. call :EXECUTE %SDP_INSTANCE_BIN_DIR%\p4d.exe -r %OFFLINE_DB_DIR% -J off -xu call :OUTPUT_TIME call :REPORT Dump out a new checkpoint file. call :EXECUTE %SDP_INSTANCE_BIN_DIR%\p4d -r %OFFLINE_DB_DIR% -jd -z %CHECKPOINTS_DIR%\%SDP_INSTANCE_P4SERVICE_NAME%.ckp.%ckp%.gz if NOT ERRORLEVEL 0 goto ERROR call :OUTPUT_TIME call :REPORT Finished! call :REPORT Upgrade was successful - see %LOG% goto END :ERROR echo An ERROR occured in the upgrade process, please check for errors in %LOG% goto END :REPORT :: Report string and save to log echo . echo %* echo .>> %LOG% echo %*>> %LOG% goto :EOF :ERROR_REPORT :: Report error and crash call :REPORT "ERROR:" echo :REPORT "%1" call :REPORT "ERROR:" goto ERROR :EXECUTE :: Execute specified command after logging it call :REPORT %* %*>> %LOG% 2>&1 goto :EOF :OUTPUT_TIME :: Use embedded for loop to turn unicode into ascii for /F "usebackq tokens=1,2 delims==" %%i in (`wmic os get LocalDateTime /VALUE 2^>NUL`) do @for /f "delims=" %%B in ("%%j") do set ldt=%%B if '.%%i.'=='.LocalDateTime.' set ldt=%ldt:~0,4%-%ldt:~4,2%-%ldt:~6,2% %ldt:~8,2%:%ldt:~10,2%:%ldt:~12,6% call :REPORT %ldt% goto :EOF :GET_JOURNAL_COUNTER :: Dump just the db.counters table to stdout and parse for the counter - parameter specifies root to look in (P4ROOT or offline_db) SETLOCAL set _root=%1 for /F "tokens=5" %%F in ('"%SDP_INSTANCE_BIN_DIR%\p4d -r %_root% -jd - db.counters | findstr @journal@"') do (set JNL=%%F) if %JNL%x == x ( call :REPORT ERROR: echo :REPORT ERROR: Could not determine journal counter; JNL not set! call :REPORT ERROR: goto ERROR ) :: Turn "@123@" to "123" set JNL=%JNL:~1,-1% ENDLOCAL & SET _result=%JNL% goto :EOF :END endlocal
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#7 | 20536 | Robert Cowham | Remove .bat files now replaced by .ps1 equivalents | ||
#6 | 16029 | C. Thomas Tyler |
Routine merge to dev from main using: p4 merge -b perforce_software-sdp-dev |
||
#5 | 15701 | C. Thomas Tyler | Routine merge down using 'p4 merge -b perforce_software-sdp-dev'. | ||
#4 | 13906 | C. Thomas Tyler |
Normalized P4INSTANCE to SDP_INSTANCE to get Unix/Windows implementations in sync. Reasons: 1. Things that interact with SDP in both Unix and Windows environments shoudn't have to account for this obscure SDP difference between Unix and Windows. (I came across this doing CBD work). 2. The Windows and Unix scripts have different variable names for defining the same concept, the SDP instance. Unix uses P4INSTANCE, while Windows uses SDP_INSTANCE. 3. This instance tag, a data set identifier, is an SDP concept. I prefer the SDP_INSTANCE name over P4INSTANCE, so I prpose to normalize to SDP_INSTANCE. 4. The P4INSTANCE name makes it look like a setting that might be recognized by the p4d itself, which it is not. (There are other such things such as P4SERVER that could perhaps be renamed as a separate task; but I'm not sure we want to totally disallow the P4 prefix for variable names. It looks too right to be wrong in same cases, like P4BIN and P4DBIN. That's a discussion for another day, outside the scope of this task). Meanwhile: * Fixed a bug in the Windows 2013.3 upgrade script that was referencing undefined P4INSTANCE, as the Windows environment defined only SDP_INSTANCE. * Had P4INSTANCE been removed completely, this change would likely cause trouble for users doing updates for existing SDP installations. So, though it involves slight technical debt, I opted to keep a redundant definition of P4INSTANCE in p4_vars.template, with comments indicating SDP_INSTANCE should be used in favor of P4INSTANCE, with a warning that P4INSTANCE may go away in a future release. This should avoid unnecessary upgrade pain. * In mkdirs.sh, the varialbe name was INSTANCE rather than SDP_INSTANCE. I changed that as well. That required manual change rather than sub/replace to avoid corrupting other similar varialbe names (e.g. MASTERINSTANCE). This is a trivial change technically (a substitute/replace, plus tweaks in p4_vars.template), but impacts many files. |
||
#3 | 11463 | Russell C. Jackson (Rusty) | Updated dev to prepare for Summit agreed changes. | ||
#2 | 11010 | Robert Cowham | Bring this into line with new upgrade.bat | ||
#1 | 10961 | C. Thomas Tyler | Merge down from main. | ||
//guest/perforce_software/sdp/main/Server/Windows/p4/common/bin/2013.3_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. |