Perforce is a tool for developers and programmers to create and develop applications. Shelving in Perforce enables the users to store and share the snapshots of files on the server. But sometimes these files are lost. If these files are deleted, how can we recover them? Let us find out.

perforce

Part 1: Recommended Way to Recover Deleted (Shelved) Files in Perforce

iMyFone D-Back is the perfect option when you are unable to recover the shelved files. Once shelved files are deleted in Perforce, it is very difficult to recover them using default built-in tools. iMyFone D-Back is a simple and friendly tool that will help the user to recover the deleted shelved files in Perforce. It only requires a few steps, and all the previously deleted files will be restored.

iMyFone D-Back works with Windows and macOS. The user only needs to select the drive, and this data recovery tool will do the rest. It will scan the drive and retrieve all the lost files, even deleted shelved files. It supports numerous file types, so the user doesn’t need to worry about it. Here are simple steps listed that allow the user to recover the deleted shelved files in Perforce.

Step 1: To recover the deleted shelved files in Perforce, you will need to download iMyFone D-Back. Install it and open it. Here, you will see a very simple tool with few options.

imyfone dback hard drive recovery

Step 2: Select the drive from where you want to recover the files. Complete the scan. When the scan finishes, iMyFone D-Back lists all the deleted files.

Step 3: Now, choose the files that you want to recover. Click on “Recover” and choose a valid path where you want to save this file.

imyfone dback all recovered files

Part 2. Recover Deleted (Shelved) Files using Perforce Built-In Tool

People that use Perforce know that shelved files are saved on the server. It is a database. If the database and files are deleted or damaged, the user can recover them because there is a backup.

To recover the database, you need to stop the server ($ p4 admin stop). Move the database to DB files ($ mv your_root_dir /DB.* /tmp). Then compare the MD5 checksum of the recent checkpoint with the checksum generated at creation. Invoke ‘p4D’ with ‘-jr’ with the recent checkpoint ($ p4d -r $P4ROOT -jr checkpoint_file). 

These commands recover the database with the last backup or checkpoint. However, if there is no backup to recover from then, you can use the third-party tools to recover the lost data.

Part 3. FAQs about Perforce Files

1 Can I Recover Previously Shelved Files?

When the shelved files are deleted, they no longer exist even in the repository. It is impossible to restore them using Perforce. But with the help of the iMyFone D-Back, you can recover those files. It is a data recovery tool that can also restore previously shelved files. Its algorithm is very powerful and brings back all the data even after months of deletion.

2 How to Shelve/Unshelve Files in Perforce?

To shelve the files, you need to right-click on the change list. Then click on “Shelve” to shelve the dialog. Now, enter a description for the new change list to shelve the files. However, you can overwrite the previous version of files with newer versions. For that, select the file, right-click on it, and then click on Shelve to overwrite the file.

To unshelve the file, you need to select the shelved files within the change list. Right-click and select the option of “Unshelve Files”. A box will pop up with the destination to unshelve the files. You can also unshelve the files by dragging the files back to the change list where you want.

3 How to Revert File to Previous Version in Perforce?

To revert the file or roll back the changes, Perforce has a feature of its own. It is a great feature, pretty much like a restoring feature, but simpler. To revert the file to the previous version, click on the folder and select the option of “Rollback”. In the rollback dialog box, preview the changes in the change list where you want the rollback to be saved. It will be restored to a specific destination.

4 How to Revert all Open Files Perforce?

To revert all open files in Perforce, there are commands available. The user first needs to use the ‘p4 revert’ command; it will discard the changes made to the open files. It will revert the files to the last synced version from the depository. The ‘p4 revert’ command also deletes or removes the files from the pending change list. However, if you are an administrator, then you can use the ‘-C’ command to revert the opened files of another user.

5 How to Delete Shelved Files in Perforce?

Once the files are shelved, they remain shelved until and unless you delete them from the pending change list. If you want to delete a shelved file from a pending change list, click on the file and click on “Delete”. Additionally, you can also click on the pending change list and choose the option of “Delete Shelved Files”.

6 How Do You Get the Shelved Change List?

To get the shelved change list, click on the ‘Search’ option and click on ‘Go To’. You can change or select the box of the Pending Change list. But now, you need to enter the number of the shelved change list. Click on “OK”.

Conclusion

Perforce has a feature of shelving the files. Shelving means storing and sharing the files on the server. It is a good feature for anyone with the power of administrator to access the files. But sometimes, shelving files are lost or deleted.

In this article, we have discussed different techniques to recover the deleted shelved files. The first method is to recover the database using the command in Perforce. But this method only works if there is a backup. If there is no backup, then you can use iMyFone D-Back. It is a data recovery tool that recovers all the lost and deleted data without any issue.