Perforce backup with rsync

First thing to know, I don’t really want to backup the entire perforce database since it’s huge and requires a lot of extra steps. I’m only backing up the latest version in case a doom fire happens to my apartment.
The scheduled backup is run on my p4 server A, in order to run a scheduled backup plan to push my newest project version to server B.

Create client(aka workspace) for the server A itself.

p4 -d `pwd` client -t Vuth_Auri -o Auri_Backup | p4 client -i
p4 client Auri_Backup

Then run a script in crontab.

51 * * * * bash /home/vuth/__backup/runBackup.sh

$cat runBackup.sh

p4 sync
rsync -rtz -e "ssh -p 1111 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /home/vuth/.ssh/id_rsa_somekey" /home/vuth/__backup/p4 vuth@123.123.123.123:/home/vuth/p4

First line get the latest version of your project to the workspace.
Second line runs rsync over a ssh connection to your remote server B.

And that’s it. Notice that this is incremental. You can add –delete to the rsync command to remove garbage from remote server B. I left it for extra safety.

Leave a Reply

Your email address will not be published. Required fields are marked *