Hi. After copying a backdrop site I get this error,
Exception: The configuration directory in settings.php is specified as './files/config_3eec97628240b19705913a4af7f7fac3/active', but this directory is either empty or missing crucial files. Check that the $config_directories variable is correct in settings.php. in _backdrop_bootstrap_configuration() (line 3020 of /data/htdocs/backdrop-sites/test2/core/includes/bootstrap.inc).
The site copy is done via a perl script, that I wrote, that I have been using for years for both drupal and backdropcms without problems. It makes an exact copy of all the site files to a new web root directory, updates the database setting in settings.php, and copies the database by dumping it from the src site and reading it back into the destination site's database.
I use it for staging production web sites sites and duplicating development sites.
settings.php contains
$config_directories['active'] = 'files/config_' . md5($database) . '/active';
$config_directories['staging'] = 'files/config_' . md5($database) . '/staging';
config_3eec97628240b19705913a4af7f7fac3/ is not the directory name of the config directory that gets copied. If I hard code settings.php on the new site with the $config_directories settings set to the actual directory name rather than using "md5($database)", the new site works just fine.
Apparently the md5() function is generating a new directory name hash and not using the existing one.
So my question is, why is it generating a new hash rather than continuing to run with the existing one on the new site while it works just fine on the old site? All the files are identical and the database is identical. I even dumped both databases and diffed them after doing the site copy to verify, and they are identical other than the database name defined at the top of the SQL dump file.
Software versions
------------------------
OS: FreeBSD 12.2-RELEASE
Backdrop version: 1.17.4
PHP version: 7.2.33
mysql version: 5.7.31
If it's on the same server then I assume it's using a different database...? If so, that'll mean a different hash between the two sites.
When Backdrop is installed, it'll change the hash code in settings.php to be the hard-coded value of the hash. If your old site has a hard-coded value in settings.php then your script can copy that to the new site.
Alternatively, you can ditch the hashed config directory names altogether and set a different default value in the default settings.php if you like. Then your site migrations will be the same. We recently added .htaccess files to protect the config directory, so securing them by obscuring the directory name is no longer needed.