How do you use the "Search and Replace tool" safely?
I am starting the process of upgrading our Moodle server from Debian 9 and Moodle 3.5 to Debian 10 and Moodle 3.9 (the upgrade itself will be another fiddly process, I'm sure, given mutually incompatible PHP requirements and availability (I plan to upgrade the OS first, with the site in maintenance mode, and then upgrade Moodle?)), and am starting by making a test server with a duplicate copy of the original site.
I have copied over and installed the Moodle data, the Moodle database, and the Moodle web files, and have updated the config.php file with the new server hostname.
Apparently, I next need to run the Search and Replace tool, to ensure that the database does not contain any references to the other server.
However, it is not clear how to run the Search and Replace tool safely.
It is accessible via the web, but via a URI that appears to be hidden (not linked from elsewhere in the admin area)(?), but, I am assuming that it would be much safer to run a tool which potentially makes major DB changes while the site is in maintenance mode? However, if the site is in maintenance mode, it is not possible to access the site, even if currently logged in as a site admin.
So would I be right to assume that it is best to run this tool from the command line instead?
php admin/tool/replace/cli/replace.php --search=//oldsitehost --replace=//newsitehost