apigee / apigee-devportal-kickstart-drupal

A fast demo and starting point for Apigee Developer Portals for Drupal
https://www.drupal.org/project/apigee_devportal_kickstart
GNU General Public License v2.0
26 stars 34 forks source link

Cloning instances between environments #346

Closed pradeepgorle13 closed 4 years ago

pradeepgorle13 commented 4 years ago

I have a devportal installed in an environment 1 and I have installed in environment 2. How can i move the changes/configuration changes that i do in the environment 2.

What I did

  1. For environment 1, I was able to capture the configurations and capture the configuration and was able to import and export that state
  2. I have installed in both the environments separately - environment 1 and environment 2, Exported the configuration changes from environment 1 and when i tried to export to environment 2, it is giving me the following error "The staged configuration cannot be imported, because it originates from a different site than this site. You can only synchronize configuration between cloned instances of this site."
  3. I installed in both the environments - environment 1 and environment 2. I replaced the devportal folder of environment 2 with the devportal from environment 1. Still I get he same error that i mentioned earlier.

How can i clone the instances of this site environment 1 to environment 2? I am very new to Drupal for all its added features and would like to use drupal instead of integrated Portal that apigee provides.

So do we have a good place where i can start with. I found one which is very old from 2011 which i am afraid i can't make use of. https://www.ostraining.com/blog/drupal/drupal-migrate/

Thanks.,

kiranjyoth commented 4 years ago

@pradeepgorle13 You can do this by setting your source UUID same as your destination UUID. This makes the config import work between sites. But you must take backups of your environments before you performing the following steps.

On Env 1 drush config-get "system.site" uuid Copy the site UUID you get, you will need this in Env 2

On Env 2 drush config-set "system.site" uuid "your_UUID_from_source_site"

Once this step is done, you can export config from Env 1 to Env 2 as both sites will have the same UUID

Thanks

pradeepgorle13 commented 4 years ago

@kiranjyoth Thanks for the answering the question. Initially, i had struggle using the drush command but when i started using the whole path "/var/www/devportal/vendor/bin/drush" instead of "drush" worked well for me .

The issue now is I got the uuid but when i ran the config-set on the second environment, /var/www/devportal/vendor/bin/drush config-set "system.site" uuid "uuid of the environment 1"

it is throwing the following attached error. Can you please help

drush-Config-set-error.txt

kiranjyoth commented 4 years ago

@pradeepgorle13 Whats the version of Drupal you have running at the moment ? You can run this at root to get details. composer show drupal/core Also if its 8.8, have you updated your settings.php as shown here, https://www.drupal.org/docs/8/update/update-core-via-composer#s-updating-settingsphp

pradeepgorle13 commented 4 years ago

@kiranjyoth The version of drupal, i am using is "version : 8.8.5".

When i have verified the settings.php

$settings['config_sync_directory'] = 'sites/default/files/config_wN6AWVe5HTGqum4F8KuOF6g7_JfFeo-YITouHwCR_pXgm46Edtxrdo23mrWfosJFMUUaW0ZnbQ/sync';

I reinstalled the drupal and was able to do the drush get-config and drush set-config. After setting it up the config, I am getting the following error.

I am currently seeing this log now in the server

2020/04/03 13:47:55 [error] 1760#0: *5 FastCGI sent in stderr: "PHP message: PDOException: SQLSTATE[HY000] [2002] No such file or directory in /var/www/devportal/web/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php on line 79 #0 /var/www/devportal/web/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php(416): PDO->__construct('mysql:host=loca...', 'devportal', 'password', Array) 1 /var/www/devportal/web/core/lib/Drupal/Core/Database/Database.php(371): Drupal\Core\Database\Driver\mysql\Connection::open(Array) 2 /var/www/devportal/web/core/lib/Drupal/Core/Database/Database.php(166): Drupal\Core\Database\Database::openConnection('default', 'default') 3 [internal function]: Drupal\Core\Database\Database::getConnection('default') 4 /var/www/devportal/web/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php(79): call_user_func_array('Drupal\Core\Dat...', Array) 5 /var/www/devportal/web/core/lib/Drupal/Component/DependencyInjection/Container.php(173): Drupal\Component\DependencyInjection\PhpArrayContainer->createService(A" while reading response header from upstream, client: 10.160.8.148, server: 10.226.192.73, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "10.226.192.73"

Also adding to that

drush config-get "system.site" uuid

getting the following error Command config-get was not found. Drush was unable to query the database. As a result, many commands are unavailable. Re-run your command with --debug to see relevant log messages.

For some reason, I am not seeing all the options for the drush command in the environment 2 but am able to see them in environment 1

kiranjyoth commented 4 years ago

@pradeepgorle13 It seems your application is not talking properly to the DB now. Is you application loading ? also pls check if your configurations are same as you fixed in the previous issue you encountered. Having said that, if have have the flexibility of re-spinning environments, why not clone Env1 to Env2 - Db, files, code and make them identical if config has to be moved from one to another ? Just a thought.

pradeepgorle13 commented 4 years ago

@kiranjyoth The application is not loading properly. When i reinstalled from first, it loaded properly and then when i updated the uuid with the envrionment 2's uuid, it gave the error that i was pointing to. Also the application was not working. Also, the option of get-config or set-config no more exists with the drush command. Any thoughts.

So when you are talking about the cloning of the Env1 to Env2 Can you please let me know where the code, files and the DB exist in the box and with what names and also can you please let me know the process for the cloning (Any step by step documentation will really work).

Thanks.

kiranjyoth commented 4 years ago

@pradeepgorle13 seems something may have been corrupt. Pls restore your env.s and try again. To answer your second question,

Location Description
Apigee Kickstart Profile files /web/profiles/contrib/apigee_devportal_kickstart During installation Apigee Kickstrart downloads all Apigee files here. You should not modify these in any way. See over-rididing guide if you need you.
Drupal Core Files /web/ Dupal core files. Never modify these as it will break your site during upgrade and may cause security issues. See over-riding guide for more details
Custom Modules/ Themes /web/modules/custom/ and /web/themes/custom/ All your custom code should lives here
File System - Public/Private /web/sites/default/files/ and /web/sites/default/private/ It is recommended that private files live outside web directory. Such as /private one level above /web directory

You would need to export the following from env 1.

  1. Source code - everything thats at /www/devportal/* - Excluding - sites/default/settings.php
  2. File System - sites/default/files/*
  3. DB - Export db from env. 1 and import it into env. 2

Hope that helps.

pradeepgorle13 commented 4 years ago

@pradeepgorle13 seems something may have been corrupt. Pls restore your env.s and try again. To answer your second question,

Location Description Apigee Kickstart Profile files /web/profiles/contrib/apigee_devportal_kickstart During installation Apigee Kickstrart downloads all Apigee files here. You should not modify these in any way. See over-rididing guide if you need you. Drupal Core Files /web/ Dupal core files. Never modify these as it will break your site during upgrade and may cause security issues. See over-riding guide for more details Custom Modules/ Themes /web/modules/custom/ and /web/themes/custom/ All your custom code should lives here File System - Public/Private /web/sites/default/files/ and /web/sites/default/private/ It is recommended that private files live outside web directory. Such as /private one level above /web directory You would need to export the following from env 1.

  1. Source code - everything thats at /www/devportal/* - Excluding - sites/default/settings.php
  2. File System - sites/default/files/*
  3. DB - Export db from env. 1 and import it into env. 2

Hope that helps.

@kiranjyoth Thanks for the instructions. As you said, I again reinstalled from database and the devportal and nginx server. Now i am able to synchronize the uuid's and the error(no import button) i was facing is gone and showing me the changes. But i am getting the below error when i am trying to import. Sorry for dragging this much as i am bit new to this framework and really want to use thisframework.

Error after importing the changes

" The configuration cannot be imported because it failed validation for the following reasons: Entities exist of type Taxonomy term and Vocabulary Tags. These entities need to be deleted before importing. Entities exist of type Taxonomy term and Vocabulary Forums. These entities need to be deleted before importing. Entities exist of type Taxonomy term and Vocabulary API Category. These entities need to be deleted before importing. Entities exist of type Paragraph and Paragraph type Title bar. These entities need to be deleted before importing. Entities exist of type Paragraph and Paragraph type Text & Image. These entities need to be deleted before importing. Entities exist of type Paragraph and Paragraph type Text. These entities need to be deleted before importing. Entities exist of type Paragraph and Paragraph type Hero. These entities need to be deleted before importing. Entities exist of type Paragraph and Paragraph type Call to Action. These entities need to be deleted before importing. Entities exist of type Paragraph and Paragraph type Card group. These entities need to be deleted before importing. Entities exist of type Paragraph and Paragraph type Card. These entities need to be deleted before importing. Entities exist of type Paragraph and Paragraph type Callout group. These entities need to be deleted before importing. Entities exist of type Paragraph and Paragraph type Callout. These entities need to be deleted before importing. Entities exist of type Paragraph and Paragraph type Button group. These entities need to be deleted before importing. Entities exist of type Paragraph and Paragraph type Button link. These entities need to be deleted before importing. Entities exist of type Paragraph and Paragraph type Blockquote. These entities need to be deleted before importing. Entities exist of type Content and Content type Basic page. These entities need to be deleted before importing. Entities exist of type Content and Content type Landing page. These entities need to be deleted before importing. Entities exist of type Content and Content type Forum topic. These entities need to be deleted before importing. Entities exist of type Content and Content type FAQ. These entities need to be deleted before importing. Entities exist of type Content and Content type Article. These entities need to be deleted before importing. Entities exist of type Media and Media type Image. These entities need to be deleted before importing. Entities exist of type Comment and Comment type Comment_forum. These entities need to be deleted before importing. Entities exist of type Comment and Comment type Default comments. These entities need to be deleted before importing. Entities exist of type Custom block and Custom block type Title bar block. These entities need to be deleted before importing. Entities exist of type Custom block and Custom block type Call to Action block. These entities need to be deleted before importing. Entities exist of type Custom block and Custom block type Basic block. These entities need to be deleted before importing. Unable to install the subtheme theme since it does not exist. "

kiranjyoth commented 4 years ago

@pradeepgorle13 Configuration import requires that you don't have the same configuration on destination which you are importing from source . For example, Vocabulary

API Category

is created during the installation process. Since your destination (env B) has this configuration already set, your config importer is complaining that it can't import on top of this existing config. This is caused because you have installed kickstart profile in Env A and Env B. Both have the same config. Now that you have made both sites' UUID same, you have to synchronize the directory where you store config. Make sure you do backups and your UUIDs are same before the next steps

  1. rsync /config/sync (or where ever you are storing these configs) of both environments.
  2. Import configuration by running drush config-import -y (or from administration screen)
  3. Once both sites have same config, you can make configuration changes on source, export it and then import on destination, without making changes from UI. This above model can also be implemented in a continuous integration pipeline by saving your configuration to your source control and deploying it to higher environments.

Here is a great article that talks about this. https://pantheon.io/docs/drupal-8-configuration-management

arunz6161 commented 4 years ago

Closing due to inactivity.