Perforce Server Backup Procedure

The Perforce server stores information in two ways. It stores metadata such as change descriptions in a relational database. It stores the actual file modifications in versioned file trees.

The metadata database is stored under the server root. The server root can be specified by the P4ROOT variable or the –r option to p4d or p4s (the Perforce server daemon and service executables). The working database consists of a group of files whose names begin with “db.”. These correspond to the tables in the database. The Perforce server also stores transaction information in a journal file which can be used to restore the “db.*” if needed. The location of the journal file can be specified by the P4JOURNAL variable or the –J option to p4d or p4s.

There is one versioned file tree per depot. The locations of the versioned file trees are defined by the depot specifications’ map field. There are three types of depots: local, spec and remote. Remote depots are depots controlled by other Perforce servers. Spec depots store the changes various specifications such as branch, client, depot, group, job, label, protect, typemap, and user. Local depots contain the files that have been submitted to the Perforce server.

The versioned file trees can be archived directly. However, you should not backup the “db.*” files. Instead, you create a checkpoint file that contains all the information needed to re-create the metadata database (“db.*” files). When you create the checkpoint, the information from the journal file is included and the journal file is truncated. Thus regular checkpoints help to keep the journal file from becoming too large. It is this checkpoint file that you should backup with the versioned file trees.

The Perforce server license file is located under the server root directory. You should back this up too.

Before backing up anything, you should insure the integrity of your data by running p4 verify and checking its output for files that are missing or whose stored md5 digest does not match the one computed for the p4 verify command. If you have errors at this point, you should read this Knowledge Base article and contact Perforce support.

You should also test your backup by performing a test restore. This type of test is needed to insure the integrity of your backups. You must do it. If you don’t, you don’t know whether your backups are working. Don’t find out the hard way.