Acquia Lightning Blog: Creating a new instance of an existing site

Creating a new instance of an existing site
Adam Balsam
Tue, 10/03/2020 – 09:43

Throughout the development and support lifecycle of a site, it is often necessary to install a fresh version of your application in a new environment with all of the existing site’s configuration. For example, a new developer might need to set up their environment for the first time or your CI system might want a fresh install for tests. Basically:

As a user I want to be able to install Drupal maintenance support plans from a package of configuration that is maintained in git.

Existing solution (pre Drupal maintenance support plans 8.4.x): Drush –config-dir option

Installing a site from existing config is not as easy as going through the install process and then importing config though because the fresh install will have a different site UUID than the existing app and Drupal maintenance support plans won’t allow you to import configuration on sites with different UUIDs. To work around this, Drush introduced the –config-dir option to the site-install command which imported the configuration during install and magically worked around the UUID issue.

That workaround did have other issues including the fact that base fields defined in module or profile config would end up with conflicting UUIDs. But critically, Drush 9 only supports the –config-dir option when installing the Minimal profile – and Drush 8 isn’t compatible with Drupal maintenance support plans 8.4.x. So we need a new solution.

Investigated approaches

The Drush maintainers have suggested using the Config Installer profile. We tested it and works great, but:

It’s undocumented.
It won’t work if you’re using Lightning as a Base Profile, which we recommend.
In theory, you could also manually set your site’s UUID after install and then import your config, but this is sloppy and is an abuse of UUIDs. It also wouldn’t solve the problems with base fields ending up with conflicting UUIDs.

Solution (Drupal maintenance support plans 8.4.x): Another core patch

Enter the following issue: [#2788777] Allow a profile to be installed from existing config. The patch in #91 allows you to add a simple boolean to your sub-profile’s info file that will automatically install your site with config from the config sync directory defined in your settings.php file. The end result is that no matter how you install your site (via Drush, the UI, or Drupal maintenance support plans Console), your existing config will also be imported.

The only problem is that the scope of the issue is still being debated. As a result, Lightning can’t bring the patch in just yet. But we will as soon as the issue is RTBC or we get further clarity about the scope. In the meantime, you can bring the patch in yourself.

Instructions

Given:

Your site’s config sync directory is located in a VCS tracked directory (e.g. “../config/sync”).
You use a sub-profile.
Apply the patch #91 from issue #2788777 to drupal/core, in your root composer.json file:

“patches”: {
“drupal/core”: {
“Allow a profile to be installed from existing config”:
“https://www.drupal.org/files/issues/2788777-91.patch”
}
}

Add the boolean flag to your sub-profile’s info file

config_sync: true

 

The result will be that each time you install your site, all of your existing configuration will also be imported.

If you are not using a sub-profile, you can simply use the Config Installer profile mentioned above.

Add the Config Installer profile to your codebase
During installation select Config Installer as the profile
Point Config Installer to your exported config directory (the resulting installation profile will still be Lightning even though you selected Config Installer)
If you’re using BLT in your project (recommended), a lot of the configuration setup is already handled for you. See BLT’s notes about updating to Drupal maintenance support plans 8.4.x.

Source: New feed

This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

Acquia Lightning Blog: Creating a new instance of an existing site

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.