Recovering Deleted Client Specification
How can I recover a deleted workspace client specification?
PROBLEM
How can I recover a deleted workspace client specification?SOLUTION
Restoring a client includes two parts:
- Recovering the client specification.
- Recovering its "state" or "have list" -- exactly what files were synched to the client.
If you have a file (for example, "myclient.txt") either from backup or the Spec depot which contains the output of 'p4 client -o myclient", you can restore the client specification "myclient" by entering:
p4 client -i < myclient.txtNote: This doesn't capture the original state of the client before it was deleted. To do that, you need to track down the relevant checkpoint or journal records.
Restoring from current journal
Assuming that you want to recover a recently deleted client that was deleted from after your last checkpoint, then you will need to recover the client specification records from your current journal file.When deleting a client, the Perforce server first deletes the associated "have" records, then the "view" records, and finally the client itself (in db.domain).
Below is a small example:
@dv@ 1 @db.have@ @//newclient/dev/py/wc.py@ @//depot/dev/py/wc.py@ 3 0 @dv@ 1 @db.have@ @//newclient/dev/py/wc2.py@ @//depot/dev/py/wc2.py@ 1 0 @dv@ 0 @db.view@ @newclient@ 0 0 @@ @@ @dv@ 3 @db.domain@ @newclient@ 99 @hiss@ @/cygdrive/c/aaa/p4work/newclient@ @@ @ @ @michael@ 1073602136 1073602136 0 1 @Created by michael. @To restore this client, you need to replay these journal records in reverse order and change the "@dv@" (delete) records into "@pv@" (put) records.
Note: If you have already restored the client and view from a text file, then you don't need to replay the db.domain or db.view records.
If you don't need the "have" records, you're done. Otherwise, you need to grep the journal for "//clientname" to extract the client records from the "db.have" table.
As the client is synced through the course of the day, the journal will reflect puts and deletes in the db.have records. If there is any such "sync" activity for the client, that sync activity should be disentangled from the client delete.
The client deletion should be a contiguous block of db.have deletes, followed by the deletion of db.view and db.domain records.
Note: Be aware that other types of extraneous records interleaved in the db.have delete blocks; such records should be removed from the resulting journal patch to avoid introducing problems.
The journal patch with the clientspec records is then replayed into your server as with any other journal fix. For example:
p4d -r $P4ROOT -jr client.patch
Restoring from Older Checkpoint
If you are trying to restore an old client whose data is in a previous checkpoint, the process is similar, but a bit easier. The old checkpoint records will have only "put" records, so there is no need to convert deletes to puts. Also, there is no need to disentangle extraneous journal entries from your grep results, since the checkpoint file does not contain any transient data.
So, to restore a clientspec from an old checkpoint, you need to generate a journal patch file by grepping the db.domain and db.view tables for the clientspec name of interest. Again, if you want the "have" records, then grep for "//client_name
The resulting patch file can be replayed into your server as above.
Note:
Using Spec Depots
Note: The spec depot does not keep track of the state of the client, but only the client specification itself. To recover the state or "have list" of the client, use the steps indicated above.
