{"id":4563,"date":"2018-01-08T13:22:33","date_gmt":"2018-01-08T13:22:33","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/?p=4563"},"modified":"2025-02-01T22:39:33","modified_gmt":"2025-02-01T22:39:33","slug":"recovery-procedures-in-perforce-server","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/recovery-procedures-in-perforce-server\/","title":{"rendered":"Recovery Procedures in Perforce Server"},"content":{"rendered":"<h2>Recovery Procedures in Perforce Server<\/h2>\n<p>If 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. it can at least provide a general guideline for recovery from the two most common situations, specifically:<\/p>\n<p>1. 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<h2><strong>Case 1: Database corruption, versioned files unaffected<\/strong><\/h2>\n<p><strong>You will need:<\/strong><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 directory, and which should therefore have been unaffected by any damage to the filesystem where your P4ROOT directory was held.<\/p>\n<p><strong>You will not need:<\/strong><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><strong>To recover the database<\/strong><\/p>\n<p>1. Stop the current instance of p4d:<\/p>\n<p>p4 admin stop<\/p>\n<p>(You must be a Perforce superuser to use p4 admin.)<\/p>\n<p>2. Rename (or move) the database (&#8220;db.*&#8221;) files:<\/p>\n<p>mv 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:<\/p>\n<p>p4d -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<h2>Case 2: Both database and versioned files lost or damaged<\/h2>\n<p><strong>You will need:<\/strong><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><strong>You will not need:<\/strong><\/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><strong>To recover the database<\/strong><\/p>\n<p>1. Stop the current instance of p4d:<\/p>\n<p>p4 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:<\/p>\n<p>p4d -r $P4ROOT -jr checkpoint_file<\/p>\n<p><strong>Some Tips While Setting up Perforce Server Configuration to have best Backup &amp; Recovery methodlogy<\/strong><\/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<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recovery Procedures in Perforce Server If the database files become corrupted or lost, either because of disk errors, a hardware failure such as a disk crash, the database can be&#8230; <\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[370],"tags":[373,4484,4486,4485],"class_list":["post-4563","post","type-post","status-publish","format-standard","hentry","category-perforce","tag-perforce","tag-perforce-backup-and-recovery","tag-perforce-recovery-process","tag-perforce-server-recovery-procedures"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/4563","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\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=4563"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/4563\/revisions"}],"predecessor-version":[{"id":4564,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/4563\/revisions\/4564"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=4563"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=4563"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=4563"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}