Skip to content

Instantly share code, notes, and snippets.

@oddurmagg
Last active August 29, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oddurmagg/8770339 to your computer and use it in GitHub Desktop.
Save oddurmagg/8770339 to your computer and use it in GitHub Desktop.
Backup Perforce Server To Amazon S3
#!/bin/bash
BACKUP_DIR=/home/perforce/backup
DEPOT_DIR=/perforce_depot
P4=/usr/local/bin/p4
HOST=localhost:1666
USER=root
S3BUCKET=s3://your-perforce-backups
export P4PASSWD=XXXX
TIME_STAMP=`date +%Y-%m-%d`
mkdir -p $BACKUP_DIR/$TIME_STAMP
# Verify the depot
$P4 -p $HOST -u $USER verify -q //... > /dev/null
$P4 -p $HOST -u $USER verify -u -q //... > /dev/null 2> /dev/null
# Take a checkpoint
$P4 -p $HOST -u $USER admin checkpoint > /dev/null
# Move all journal and checkpoint files to the backup folder
mv $DEPOT_DIR/journal.* $BACKUP_DIR/$time_stamp
mv $DEPOT_DIR/checkpoint.* $BACKUP_DIR/$time_stamp
s3cmd sync $BACKUP_DIR/$TIME_STAMP $S3BUCKET
rm -fr $BACKUP_DIR/$TIME_STAMP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment