I’ve seen a lot of time when we get stuck with a client environment where we need to perform UAT refresh from PROD or create a test environment for us to support client environment. We can create replica by taking full farm backup .But, what is we are creating a replica of an environment manually and we do not have WSP backup file or source code for the solution deployed in the farm. There is no option left for us to deploy the same solution into another environment without this two approaches.

For these kind of situations, please use below mentioned Powershell command
$farm = Get-SPFarm
$file = $farm.Solutions.Item(“solution.wsp”).SolutionFile

This way, we can take backup of the solution which is already deployed into the server farm and can re-use it into another environment.