How to recover a Plastic SCM repository
(This article applies to on-premise servers only. To recover a Cloud repo, contact support).
Some background things first: when you delete a Plastic SCM repository, you are just detaching the repository from the repositories index. It's not truly removed from disk and you can still recover it. There are two things you will need to do to recover the repository. The first one is knowing the missing repository ID. The second one is re-adding the repository to the Plastic SCM server.
Finding the missing repository ID
At the end of the day, the a Plastic SCM repository is a database and the repository ID is part of the name of the database (MySQL, SQLServer, sqlite) or the name of the directory where the data is stored (Jet).
This is an example of the Jet database directory:
As the repository has been removed, it will not be visible at the repositories view or by the "cm lrep" command. We need to check the 'audit.log' file to retrieve not only the missing repository id but also its name. Search by "Repository deleted" and you will get all the repositories that have been removed. The 'audit.log' can be found inside the Plastic SCM server directory.
IhxdTQhlxKO6+tr0P7QbbW0ZC3VlE2B6DreT4RHk75Y= manu (DESKTOP-FOPHPKU) 8/28/2018 4:16:18 PM : Repository deleted: engine (5)
Once you identify the missing repository, it is time to re-add it.
Re-adding the missing repository
The command line interface is able to add repositories. You will need to use the "cm addrep" command as follows:
> cm addrep rep_5 engine plastic-srv:8087
Let's walk though the parameters:
- rep_5: is the repository that was removed, 'rep_' is the database prefix and 5 the repository ID.
- engine: Is the name of the repository. It's not mandatory to preserve the original name of the repository but it's a good practice if the missing repository was used by an xlink.
- plastic-srv:8087: The Plastic SCM server where the missing repo exists.
After executing the command, you will be able to use the re-added repository.
How to prevent a repository removal
There are at least two different ways to prevent the removal operation from happening. The first one is prevented by using the Plastic SCM security; use the "rmrep" permission to only permit admins to remove repositories. For more information, click: https://www.plasticscm.com/documentation/security/plastic-scm-version-control-security-guide.shtml#Motivation
The second prevention method is using a Plastic SCM trigger. Click here for more information: http://blog.plasticscm.com/2012/02/remove-repository-trigger.html