{"id":1720,"date":"2017-12-06T04:59:47","date_gmt":"2017-12-06T04:59:47","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/?p=1720"},"modified":"2025-02-01T22:39:34","modified_gmt":"2025-02-01T22:39:34","slug":"recovery-procedures-in-perforce","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/recovery-procedures-in-perforce\/","title":{"rendered":"Recovery Procedures in Perforce"},"content":{"rendered":"<p><strong>rajeshkumar created the topic: Recovery Procedures in Perforce<\/strong><br \/>\nIf the database files become corrupted or lost, either because of disk errors, a hardware failure such as a disk crash, the database can be recreated with your stored checkpoint and journal.<\/p>\n<p>it can at least provide a general guideline for recovery from the two most common situations, specifically:<br \/>\n1. corruption of your Perforce database only, without damage to your versioned files, and<br \/>\n2. corruption to both your database and versioned files.<\/p>\n<p>Case 1: Database corruption, versioned files unaffected<\/p>\n<p>You will need:<br \/>\n1. The last checkpoint file, which should be available from the latest P4ROOT directory backup.<\/p>\n<p>2. The current journal file, which should be on a separate filesystem from your P4ROOT<br \/>\ndirectory, and which should therefore have been unaffected by any damage to the<br \/>\nfilesystem where your P4ROOT directory was held.<\/p>\n<p>You will not need:<br \/>\n1. Your backup of your versioned files; if they weren\u2019t affected by the crash, they\u2019re already up to date.<\/p>\n<p>To recover the database<\/p>\n<p>1. Stop the current instance of p4d:<br \/>\np4 admin stop<br \/>\n(You must be a Perforce superuser to use p4 admin.)<\/p>\n<p>2. Rename (or move) the database (&#8220;db.*&#8221;) files:<br \/>\nmv your_root_dir\/db.* \/tmp<\/p>\n<p>There can be no db.* files in the $P4ROOT directory when you start recovery from a checkpoint. Although the old db.* files are never used during recovery, it\u2019s good practice not to delete them until you\u2019re certain your restoration was successful.<\/p>\n<p>3. Invoke p4d with the -jr (journal-restore) flag, specifying your most recent checkpoint and current journal. If you explicitly specify the server root ($P4ROOT), the -r $P4ROOT argument must precede the -jr flag:<br \/>\np4d -r $P4ROOT -jr checkpoint_file journal_file<\/p>\n<p>This recovers the database as it existed when the last checkpoint was taken, and then apply the changes recorded in the journal file since the checkpoint was taken.<\/p>\n<p>Case 2: Both database and versioned files lost or damaged<\/p>\n<p>You will need:<br \/>\n1. The last checkpoint file, which should be available from the latest P4ROOT directory backup.<br \/>\n2. Your versioned files, which should be available from the latest P4ROOT directory backup.<\/p>\n<p>You will not need:<\/p>\n<p>Your current journal file. The journal contains a record of changes to the metadata and versioned files that occurred between the last backup and the crash; because you\u2019ll be restoring a set of versioned files from a backup taken before that crash, the checkpoint alone contains the metadata useful for the recovery, and the information in the journal is of limited or no use.<\/p>\n<p>To recover the database<\/p>\n<p>1. Stop the current instance of p4d:<br \/>\np4 admin stop<br \/>\n(You must be a Perforce superuser to use p4 admin.)<\/p>\n<p>2. Rename (or move) the corrupt database (&#8220;db.&#8221;) files:<br \/>\nmv your_root_dir\/db.* \/tmp<\/p>\n<p>The corrupt db.* files aren\u2019t actually used in the restoration process, but it\u2019s safe practice not to delete them until you\u2019re certain your restoration was successful.<\/p>\n<p>3. Invoke p4d with the -jr (journal-restore) flag, specifying only your most recent checkpoint:<br \/>\np4d -r $P4ROOT -jr checkpoint_file<\/p>\n<p>Some Tips While Setting up Perforce Server Configuration to have best Backup &#038; Recovery methodology<\/p>\n<p>1. Make sure you are using Symbolic Links for storing versioned files in another drive<br \/>\n2. Make sure you are Storing Journal files in differnet directory<br \/>\n2. Make sure you are storing check points in different directory<br \/>\nRegards,<br \/>\nRajesh Kumar<br \/>\nTwitt me @ <a href=\"http:\/\/twitter.com\/RajeshKumarIn\" target=\"_blank\" rel=\"noopener\">twitter.com\/RajeshKumarIn<\/a><\/p>\n<p><strong>rajeshkumar replied the topic: Re: Recovery Procedures in Perforce<\/strong><br \/>\nReference can be found in following link&#8230;<br \/>\n<a href=\"http:\/\/community.scmgalaxy.com\/pg\/blog\/rajeshku...s-in-perforce-server\" target=\"_blank\" rel=\"noopener\">community.scmgalaxy.com\/pg\/blog\/rajeshku&#8230;s-in-perforce-server<\/a><br \/>\nRegards,<br \/>\nRajesh Kumar<br \/>\nTwitt me @ <a href=\"http:\/\/twitter.com\/RajeshKumarIn\" target=\"_blank\" rel=\"noopener\">twitter.com\/RajeshKumarIn<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>rajeshkumar created the topic: Recovery Procedures in Perforce If the database files become corrupted or lost, either because of disk errors, a hardware failure such as a disk crash, the&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[370],"tags":[373],"class_list":["post-1720","post","type-post","status-publish","format-standard","hentry","category-perforce","tag-perforce"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/1720","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=1720"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/1720\/revisions"}],"predecessor-version":[{"id":1721,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/1720\/revisions\/1721"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=1720"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=1720"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=1720"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}