[SCM] source code management-Backup Recovery and upgrade of perforce

Source: Internet
Author: User
Tags perforce

 

I. file type on p4server

0) file composition of p4server:

 

1) file types such:

2) All files in the depot directory and directory are actually submitted by the developer.CodeFile Information, we become versioned files;

(Files in depot are in the RCS format, refer to: http://durak.org/sean/pubs/software/cvsbook/RCS-Format.html)

For example, changlist:

The corresponding files in depot are: versiontest.txt, V

Head 1.75 ;
Access ;
Symbols ;
Locks ; Comment @@ ;

1.75
date 2010.06 . 21.22 . 56.05 ; author P4 ; state exp ;
branches ;
next 1.74 ;

1.74
Date2010.06.21.22.55.30;Author p4;State exp;
Branches;
Next;

Desc
@@

1.75
Log
@@
Text
@111

222@

1.74
Log
@@
Text
@ D13
A31
111@

 

3) The db. * file is the database file of the P4 server. Each dB. * is equivalent to a table of a database. In many cases, this is also called metadata. Stores all the DivisionSource codeInformation of other P4 servers, such as users, groups, depots, changes, labels, and jobs...

4) The checkpoint + journal file is the backup file of the database of P4 server. Checkpoint is an image of all dB. * files at a time point. Journal is the operation record of P4 server after a checkpoint.

 

For example, when you create a checkpoint, checkpoint.5 and journal.4 are generated. In fact, the content of checkpoint.5 is equal to the content of checkpoint.4 plus the content of journal.4, journal.4 contains all the operations between checkpoint.4 and checkpoint.5. Operations after the latest checkpoint are recorded in the Journal File.

 

 

2. backup and recovery files

1) P4 server backup must back up versioned files and checkpoint + Journal at the same time.

2) the P4 server backup and recovery process is as follows:

Three backups

1) Verify server integrity and add MD5 information and file length information to the database of P4 for the files modified after the last backup:

P4 verify //... or P4 verify-qz //...

By running P4 verify before backup, you can ensure that the MD5 and file length information of the files modified after the last backup are also recorded in the P4 dB. P4 verify not only identifies server issues before backup, but also verifies that the recovery is correct.

2) create a checkpoint. Run the command p4d with the parameter-JC (Journal-create). This step actually contains creating a checkpoint and then saving the journal as the old journal, create a new journal file to record future changes:
P4d-JC

Alternatively, you can use the P4 admin command. P4 admin needs to set the environment variable p4port and p4user, or execute the command on a remote machine:

P4 admin checkpoint

 

3) before backing up any files, ensure that the checkpoint is successfully created. You can check the return value of p4d-JC to determine whether the checkpoint is successfully created or whether the corresponding journal is created.

4) Once the checkpoint is successfully created, you can back up the checkpoint file, the old journal file, and versioned files.

 

When a checkpoint is created, the perforce database is locked. Therefore, the best way is to manually create an offline database during the first backup, In subsequent backup, apply the latest journal to the offline database, and then back up the offline database. .

In Versions later than 2010.2, you can create a replicated server dedicated to creating backups.

By default, checkpoint and journal are created in the directory set by p4root,P4d-JCPrefix To create checkpoint and journal to a new directory. After the prefix parameter is used, the names of checkpoint and journal will changePrefix. CKP. N and prefix. JNL. n-1.

 

Usually we use p4journal or-J filename for p4d [-JC] to generate the current journal to a different location than p4root. Avoid the loss of modifications after the last checkpoint when the p4root directory is faulty. If the-J filename parameter is used at P4 server startup, you must use-J filename to specify the correct Journal File during checkpoint. For example:
# Start Server
$ P4d-r $ p4root-P 1666-J/usr/local/perforce/journalfile
# Create a checkpoint
$ P4d-r $ p4root-J/usr/local/perforce/journalfile-JC
Checkpointing to checkpoint.19...
Saving journal to journal.18...
Truncating/usr/local/perforce/journalfile...

 

IV recovery

1) stop the current p4server instance:
P4 admin stop
(It must be P4 supperuser or admin to use P4 Admin .)

2) Rename or remove the old dB. * file:
MV your_root_dir/DB. */tmp

It is better to move the old dB. * to a backup directory and delete the old dB. * file after ensuring that all the recovery is correct.

3) use the command p4d and the parameter-Jr (Journal-Restore) to restore the file, and specify the latest checkpoint and the current Journal File. If you need to specify serverroot, the-r $ p4root parameter must be prior to-JR:
P4d-r $ p4root-Jr checkpoint_file journal_file

(Or simply restore to the last checkpoint: p4d-r $ p4root-Jr checkpoint_file)
If only the last checkpoint is restored, the modification after the checkpoint is not restored. If you use the-Z parameter to compress the checkpoint during backup, you need to separately restore the journal during restoration, that is, run the following command:
P4d-r $ p4root-Jr checkpoint_file journal_file
It is divided into two commands:
P4d-r $ p4root-z-Jr checkpoint_file.gz
P4d-r $ p4root-Jr journal_file
When -zstack is used, the suffix .gz must be explicitly specified, and-r $ p4root must be prior to parameter-Jr.

4) after the recovery is complete, use P4 verify for verification to ensure that versioned files is new to the database:
P4 verify-Q //...
This command verifies the new version of versioned files. -The Q Parameter indicates that only error messages are output. Normally, this command has no output.

 

5. Best practices

1) Back up versioned files and checkpoint + journal to different drives.

2) When p4d is started, use-J to specify the location of the latest journal, because the latest journal has not been backed up before crash.

 

Upgrade p4server

1) Stop p4server;

2) create a checkpoint and back up the old p4d file;

3rd. Use the new p4dto replace the old one. You can also use perforce.exe on Windows to reinstall the new p4d;

4) use the command to upgrade Database: p4d-r server_root-J journal_file-Xu;

5) Restart p4server after the upgrade is successful;

 

Complete!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.