I am not sure this will work the way you imagine. I could be wrong.
I am assuming that both sites are on the same Apache server. I am also assuming that your sites are set up as
example.com and not
testrun.example.com. Most of the time, a site on Apache would set up as
example.com would have an IP address assigned in the DNS.
www.example.com would be a
CNAME that points to
example.com. I am working on this premise.
Generally Apache is assigned IP addresses and ports to listen to in the
ports.conf file. Websites within Apache are not normally assigned IP addresses. You will have to check your configuration files. If this is the case, then Apache will take any packet in regardless of the IP address and process them the same.
Apache will take the request packet, examine the to address and try and match it to a website. It may still try and match any request sent to
example.com and not to
testrun.example.com. This is because the request packet will not be addressed to
Check your configuration files.
Your can find your Apache configuration files in
/etc/local/apache2/. Check the
ports.conf file and you should see both IP addresses. You will find your site specific configuration files in
/sites-available/. The file name format would be
sub-domain.domainname.tld.conf. Check both files for the existence of your IP addresses.
If you do not see the IP addresses in the site configuration files, then I would say that I do not believe your idea will work. If you do, then I would say perhaps- try it.
If you can afford a short period of downtime, then you can experiment and try this scenario easily. Otherwise, if up time is critical, I would not mess around and simply deploy your new site over your old site only after two complete backups are completed that you are sure you can use to restore the site.
In fact, the other answer to change the directory should also work and could easily be backed out if you change your mind.