p4 journalcopy


Copies journal data from a master server to the local file system of a standby replica. The copy is identical, byte-for-byte, to the original.


p4 [g-opts] journalcopy [-i n] [-b wait]
p4 [g-opts] journalcopy -l


The p4 journalcopy provides two syntax variants:

  • The first variant copies journal data to the local file system of a standby replica.

  • The second variant displays information about the current copy position from the master's journal to the replica's journal.

A standby replica provides an easier mechanism for failover than a readonly replica. In order for a standby replica to take over for the master server, it must have a copy of the master server's metadata and versioned files. To do this, you must run the following commands:

  • One or more p4 pull -u command to replicate the versioned files.

  • The p4 journalcopy command to copy the master's journal file to the local file system of the standby replica. This command does not apply the copied journal records to the replica's database.

  • The p4 pull -L command to retrieve the journal records from journal files created by the p4 journalcopy and to apply these to the replica's database.

The combination of the p4 journalcopy command and the p4 pull -L command accomplish the same result as using the p4 pull command, with the following differences:

  • Journal files are copied before the database is updated.

  • Copied files are physically identical to the master's journal, not just logically equivalent.

    Having an identical copy of the journal files is useful for failover because other servers in your installation, which will have stored physical byte offsets into the master journal files in their state files, do not have to adjust those offset positions during failover; they just switch their target to the new master and continue replicating from it.

  • An additional statefile is used to coordinate the p4 journalcopy and the p4 pull -L commands.

An operator may run the p4 journalcopy -l, p4 pull -l -j, and p4 pull -l -s commands. This makes it possible for an operator to confirm the state of a replica.

The p4 journalcopy command runs very quickly, so journal records can be transferred from the master server to the standby replica with very little lag and with very little overhead on the master server.

The output of the p4 journalcopy -l command is shown below. The sequence number indicates the offset position in the journal that the copy has reached.

Current replica persisted journal state is: Journal 2, Sequence 6510347

You can compare this offset with the output for the p4 pull -l command for the replica. The latter indicates the offset position in the journal that has been written to the database.


-b wait

Wait the specified number of seconds to retry the p4 journalcopy command after a failed attempt. The default value is 60 seconds.

-i n

Repeat the p4 journalcopy command every n seconds. If you do not use this option or if n is 1, the command runs once.

If you set n to 0, the command will get journal records from the master as soon as they are available.


Report on the current position in the copied journal.


See “Global Options”.

Usage Notes

Can File Arguments Use Revision Specifier?

Can File Arguments Use Revision Range?

Minimal Access Level Required





p4 journalcopy -i 3

Run the command every three seconds.

Related Commands

To make a copy of the master's versioned files.

p4 pull -u

To get information about replication status from the point of view of the master server, use the -J option of the p4 servers command.

p4 servers