How to Backup Perforce Server
Regular backups of your Perforce data are vital. The key concepts are:
- Make sure journaling is active
- Create checkpoints regularly, and
- Use p4 verify regularly
- Versioned files
A checkpoint is a snapshot or copy of the database at a particular moment in time.
A journal is a log that records updates made to the database since the last snapshot was taken.
How to Make sure journaling is active
For UNIX installations, journaling is also automatically enabled. If P4JOURNAL is left unset (and no location is specified on the command line), the default location for the journal is $P4ROOT/journal.
How to create a checkpoints
To create a checkpoint, invoke the p4d program with the -jc (journal-create) flag:
p4d -r root -jc
You can create a checkpoint while the Perforce server (p4d) is running. The checkpoint is created in your server root directory (P4ROOT).
To make the checkpoint, p4d locks the database and then dumps its contents to a file named checkpoint.n in the P4ROOT directory, where n is a sequence number.
To create a checkpoint without being logged in to the machine running the Perforce server, use the command:
p4 admin checkpoint [-z] [prefix]
Your checkpoint and journal files are used to reconstruct the Perforce database files only. Your versioned files are stored in directories under the Perforce server root, and must be backed up separately.
1. Verify the integrity of your server and add MD5 digests and file length metadata to any new files:
p4 verify //…
You may wish to pass the -q (quiet) option to p4 verify. If called with the -q option, p4 verify produces output only when errors are detected.
2. Make a checkpoint by invoking p4d with the -jc (journal-create) flag, or by using the p4 admin command. Use one of:
p4 admin checkpoint
3. Ensure that the checkpoint has been created successfully before backing up any files. (After a disk crash, the last thing you want to discover is that the checkpoints you’ve been backing up for the past three weeks were incomplete!) You can tell that the checkpoint command has completed successfully by examining the error code returned from p4d -jc, or by observing the truncation of the current journal file.
4. Once the checkpoint has been created successfully, back up the checkpoint file, the old journal file, and your versioned files.
- Use separate physical drives for server root and journal
- Use protections and passwords: Until you define a Perforce superuser, every Perforce user is a Perforce superuser, and can run any Perforce command on any file. After starting a new Perforce server, use:> p4 protect and To set (or reset) a user’s password, use p4 passwd username (as a Perforce superuser),
- Allocate disk space for anticipated growth