remove_old_checkpoints.bat #3

  • //
  • guest/
  • perforce_software/
  • sdp/
  • main/
  • Server/
  • Windows/
  • p4/
  • common/
  • bin/
  • remove_old_checkpoints.bat
  • View
  • Commits
  • Open Download .zip Download (3 KB)
:: ============================================================================
:: 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
:: ----------------------------------------------------------------------------

@echo off

set CkpNum=%1
set KeepCkpNum=%2

if %CkpNum%x == x (
   echo Usage Error: remove_old_checkpoints.bat CkpNum KeepCkpNum
   exit /b 1
)

if %KeepCkpNum%x == x (
   echo Usage Error: remove_old_checkpoints.bat CkpNum KeepCkpNum
   exit /b 1
)

:: I = Highest checkpoint number to remove.
set /A I="CkpNum - KeepCkpNum"

:: J = Highest journal number to remove.
set /A J="I - 1"

if %KeepCkpNum%x == x (
   echo Warning: KeepCkpNum not defined.  No old checkpoints deleted.
   exit /b 1
)

if %KeepCkpNum% == 0 (
   echo Info: KEEPCKPS set to 0.  No old checkpoints deleted.
   exit /b 0
)

if %CHECKPOINTS_DIR%x == x (
   echo Warning: CHECKPOINTS not defined.  No old checkpoints deleted.
   exit /b 1
)

if %SDP_INSTANCE_P4SERVICE_NAME%x == x (
   echo Warning: P4SERVICE not defined.  No old checkpoints deleted.
   exit /b 1
)

if %KeepCkpNum% == 0 (
   echo .
   echo Skipping cleanup of old checkpoint files because KEEPCKPS is set to 0.
   echo .
   exit /b 0
)

echo Removing old checkpoint and journal files.
echo Keeping latest %KeepCkpNum%, per KEEPCKPS setting in sdp_config.ini.
echo Latest checkpoint file is number %CKP%.
echo .

if %I% LSS 8 (
   echo No checkpoint or journal files need to be deleted.
   echo .
   exit /b 0
) ELSE (
   echo Deleting existing checkpoints numbered 8-%I%.  Delete 1-7 manually.
   echo Deleting existing journals numbered 7-%J%.  Delete 1-6 manually.
   echo .
)

set ORIG_DIR=%CD%
cd /D "%CHECKPOINTS_DIR%"

for /L %%C in (%I%, -1, 8) do (
   if exist %SDP_INSTANCE_P4SERVICE_NAME%.ckp.%%C.gz (
      echo DEL /F /Q %SDP_INSTANCE_P4SERVICE_NAME%.ckp.%%C.gz
      DEL /F /Q %SDP_INSTANCE_P4SERVICE_NAME%.ckp.%%C.gz
      DEL /F /Q %SDP_INSTANCE_P4SERVICE_NAME%.ckp.%%C.gz.md5
   )
)

for /L %%D in (%J%, -1, 7) do (
   if exist %SDP_INSTANCE_P4SERVICE_NAME%.jnl.%%D.gz (
      echo DEL /F /Q %SDP_INSTANCE_P4SERVICE_NAME%.jnl.%%D.gz
      DEL /F /Q %SDP_INSTANCE_P4SERVICE_NAME%.jnl.%%D.gz
   )
   if exist %SDP_INSTANCE_P4SERVICE_NAME%.jnl.%%D (
      echo DEL /F /Q %SDP_INSTANCE_P4SERVICE_NAME%.jnl.%%D
      DEL /F /Q %SDP_INSTANCE_P4SERVICE_NAME%.jnl.%%D
   )
)

echo Checkpoint and journal file cleanup complete.
echo .

cd /d "%ORIG_DIR%"

exit /b 0
# Change User Description Committed
#4 20767 C. Thomas Tyler Released SDP 2016.2.20755 (2016/09/29).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#3 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.
#2 14788 Russell C. Jackson (Rusty) Added clean up of uncompressed journals.
#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.