#!/bin/sh
#*******************************************************************************
#* Name         : p4d.checkpoint
#* Description  : Take checkpoint of Perforce database
#*******************************************************************************

. /etc/default/p4d

# Run this to calculate and store checksums on older servers:
# /bin/su - perforce -c ". /etc/default/p4d; /usr/bin/p4 verify -qu //..." 

# Take a (compressed) checkpoint.
/bin/su - perforce -c ". /etc/default/p4d; /usr/bin/p4d -z -jc" 

# Remove all checkpoints/journals older than 2 weeks
find $P4ROOT -maxdepth 1 \
	\( -name checkpoint.\[0-9\]\*.gz -o \
        -name journal.\[0-9\]\*.gz \) \
        -a -mtime +14 |\
        xargs rm -f