Last active
August 29, 2015 13:55
-
-
Save oddurmagg/8770339 to your computer and use it in GitHub Desktop.
Backup Perforce Server To Amazon S3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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