:: ============================================================================ :: Copyright and license info is available in the LICENSE file included with :: the Server Deployment Package (SDP), and also available online: :: https://swarm.workshop.perforce.com/projects/perforce-software-sdp/view/main/LICENSE :: ---------------------------------------------------------------------------- :: This script must run via task scheduler under a login that has access to the %REMOTE_DEPOTDATA_ROOT% :: share on the master server. That same login also has to have access to the replica server. @echo off set current_script_dir=%~p0 call %current_script_dir%p4env.bat %1 if errorlevel 1 ( echo Weekly Sync Replica aborted - invalid config file found. echo . exit /B 1 ) if x%SDP_INSTANCE% == x ( echo Weekly Sync Replica aborted - no instance specified. echo . exit /B 1 ) @echo off set LOG=%LOGS_DIR%\weekly_sync_replica.log echo Start Weekly Sync Replica > %LOG% 2>&1 date /t >> %LOG% 2>&1 time /t >> %LOG% 2>&1 :: Check if we are in admin mode - things won't work otherwise - can't stop the service. net session > NUL 2>&1 IF not %ERRORLEVEL% EQU 0 ( ECHO You must run weekly_sync_replica.bat with Administrator privileges.>> %LOG% goto ERROR ) :: Need to login to the Master server (via P4TARGET) if not exist %ADMIN_PASS_FILE% ( set errmsg=Can't find admin password file %ADMIN_PASS_FILE% echo %errmsg% exit /b 1 ) %SDP_INSTANCE_BIN_DIR%\p4 -p %P4TARGET% -u %SDP_P4SUPERUSER% login -a < %ADMIN_PASS_FILE% if not %ERRORLEVEL% EQU 0 goto ERROR if NOT ERRORLEVEL 0 goto ERROR echo xcopy /D /I %REMOTE_CHECKPOINTS_DIR%\*.* %CHECKPOINTS_DIR%\*.* >> %LOG% 2>&1 xcopy /D /I %REMOTE_CHECKPOINTS_DIR%\*.* %CHECKPOINTS_DIR%\*.* >> %LOG% 2>&1 echo Determining current journal counter with 'p4 counter journal'.>> %LOG% for /F %%F in ('%SDP_INSTANCE_BIN_DIR%\p4 -p %P4TARGET% -u %SDP_P4SUPERUSER% counter 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:>>%LOG% goto ERROR ) echo Journal counter %JNL% found.>> %LOG% set /a REMOVEJNL=%JNL%-%KEEPCKPS%-1 >> %LOG% 2>&1 echo attrib -r %CHECKPOINTS_DIR%\*.%REMOVEJNL%.* >> %LOG% 2>&1 attrib -r %CHECKPOINTS_DIR%\*.%REMOVEJNL%.* >> %LOG% 2>&1 echo del %CHECKPOINTS_DIR%\*.%REMOVEJNL%.* >> %LOG% 2>&1 del %CHECKPOINTS_DIR%\*.%REMOVEJNL%.* >> %LOG% 2>&1 echo del %OFFLINE_DB_DIR%\db.* >> %LOG% 2>&1 del %OFFLINE_DB_DIR%\db.* >> %LOG% 2>&1 REM Unset P4NAME to allow p4d 2012.2 to recover checkpoint set P4NAME= echo %SDP_INSTANCE_BIN_DIR%\p4d.exe -r %OFFLINE_DB_DIR% -jr -z %CHECKPOINTS_DIR%\p4_%REMOTE_SDP_INSTANCE%.ckp.%JNL%.gz >> %LOG% 2>&1 %SDP_INSTANCE_BIN_DIR%\p4d.exe -r %OFFLINE_DB_DIR% -jr -z %CHECKPOINTS_DIR%\p4_%REMOTE_SDP_INSTANCE%.ckp.%JNL%.gz >> %LOG% 2>&1 echo Stopping %SDP_INSTANCE_P4SERVICE_NAME% >> %LOG% 2>&1 net stop %SDP_INSTANCE_P4SERVICE_NAME% >> %LOG% 2>&1 del %LOGS_DIR%\log >> %LOG% 2>&1 del %LOGS_DIR%\journal >> %LOG% 2>&1 cd %P4ROOT% >> %LOG% 2>&1 del %P4ROOT%\save\db.* >> %LOG% 2>&1 echo Moving %OFFLINE_DB_DIR%\db.* to %P4ROOT% >> %LOG% 2>&1 move db.* %P4ROOT%\save >> %LOG% 2>&1 move %OFFLINE_DB_DIR%\db.* %P4ROOT% >> %LOG% 2>&1 echo Removing state files >> %LOG% 2>&1 del state >> %LOG% 2>&1 del rdb.lbr >> %LOG% 2>&1 echo Starting %SDP_INSTANCE_P4SERVICE_NAME% >> %LOG% 2>&1 net start %SDP_INSTANCE_P4SERVICE_NAME% >> %LOG% 2>&1 echo %SDP_INSTANCE_BIN_DIR%\p4d.exe -r %OFFLINE_DB_DIR% -jr -z %CHECKPOINTS_DIR%\p4_%REMOTE_SDP_INSTANCE%.ckp.%JNL%.gz >> %LOG% 2>&1 %SDP_INSTANCE_BIN_DIR%\p4d.exe -r %OFFLINE_DB_DIR% -jr -z %CHECKPOINTS_DIR%\p4_%REMOTE_SDP_INSTANCE%.ckp.%JNL%.gz >> %LOG% 2>&1 echo End Weekly Sync Replica >> %LOG% 2>&1 date /t >> %LOG% 2>&1 time /t >> %LOG% 2>&1 set ERRORTEXT= goto SKIP_ERROR :ERROR echo ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR >> %LOG% 2>&1 echo Weekly Sync Replica Failed >> %LOG% 2>&1 echo Weekly Sync Replica Failed - please see %LOG% echo . echo ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR - ERROR >> %LOG% 2>&1 set ERRORTEXT=Weekly Sync Replica Failed! :SKIP_ERROR %SCRIPTS_DIR%\blat.exe -install %mailhost% %mailfrom% %SCRIPTS_DIR%\blat.exe %LOG% -to %maillist% -subject "%ERRORTEXT% %COMPUTERNAME% %SDP_INSTANCE_P4SERVICE_NAME% Weekly Sync Replica log" if "%ERRORTEXT%x" == "x" ( echo . echo Weekly Sync Replica completed successfully! See %LOG% ) :END
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 19278 | trina | "Forking branch Main of perforce-software-sdp to trina-sdp." | ||
//guest/perforce_software/sdp/main/Server/Windows/p4/common/bin/weekly_sync_replica.bat | |||||
#2 | 15856 | C. Thomas Tyler |
Replaced the big license comment block with a shortened form referencing the LICENSE file included with the SDP package, and also by the URL for the license file in The Workshop. |
||
#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. |