Answers.Body: <p>I have setup CiviCRM with drupal 8 and 9 few times and here is how i would do it.</p>
  <p><strong>Prep</strong></p>
  <p>1- Check your machine supports at-least the minimum PHP and MySQL versions
  <a href="https://docs.civicrm.org/installation/en/latest/general/requirements/" rel="nofollow noreferrer">https://docs.civicrm.org/installation/en/latest/general/requirements/</a></p>
  <p>2-First Install Drupal 9 and have it working 100%.</p>
  <p>3-Then use the cv command line tool (my preference) to install civi, specially if you want to install civi in separate database than the Drupal one and check this link for other requirements.
  <a href="https://docs.civicrm.org/installation/en/latest/drupal8/" rel="nofollow noreferrer">https://docs.civicrm.org/installation/en/latest/drupal8/</a></p>
  <p>4 - move over your modules or other dependency stuff such as composer</p>
  <p>5- Fix whatever issues that popup etc</p>
  <p><strong>For: Drupal 9:</strong></p>
  <p>1- Note that Drupal 9 has higher PHP, Apache and MySQL requirement, so check below link to meet those. My personal preference is since Drupal 10 isn't too far and it will require PHP 8, to just go straight to PHP 8 (supported by latest Civi and Drupal 9).</p>
  <p><a href="https://www.drupal.org/docs/understanding-drupal/how-drupal-9-was-made-and-what-is-included/environment-requirements-of-drupal-9" rel="nofollow noreferrer">https://www.drupal.org/docs/understanding-drupal/how-drupal-9-was-made-and-what-is-included/environment-requirements-of-drupal-9</a></p>
  <p><a href="https://www.drupal.org/docs/system-requirements/php-requirements" rel="nofollow noreferrer">https://www.drupal.org/docs/system-requirements/php-requirements</a></p>
  <p>2 - Other steps will be similar to above one. You would install Drupal first and get it working, then copy your modules that support Drupal 9 and fix comparability issues.</p>
  <p>3 - Then you would install Civi 5.4.2 or latest version that supports Drupal 9.</p>
  <p>4 - Consult with below links if the official install links  for Drupal 9 don't work for Civi.</p>
  <p><a href="https://civicrm.stackexchange.com/questions/35746/what-is-the-status-of-civicrm-working-with-drupal-9">What is the status of CiviCRM working with Drupal 9?</a></p>
  <p><a href="https://civicrm.stackexchange.com/questions/40620/cant-install-civicrm-with-drupal-9-2-7">Can&#39;t install civiCRM with drupal 9.2.7</a></p>
  <ul>
  <li>my recommendation is if your final destination is Drupal 9, just go straight to that and save time, unless you have other requirements that need Drupal 7.8.2</li>
  </ul>
  <p>Good luck.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-10T20:04:52.190Z
Answers.Text: I don't think this answers the problem. as i read it Tony has civi on d7 and wants to move it to d9
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-10T20:21:36.577Z
Answers.Text: Updated the answer!
Answers.UserDisplayName: salah-1
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-11T21:50:15.947Z
Answers.Text: i think your answer is missing the main point. i may be wrong. but if you already have civicrm on d7, and you build a d9 site, and then you want to move the civicrm from the d7 site to the d9 site, what steps do you need to take eg are they 1/ update civi to latest on d7 2/ install same version via composer on d9 site, 3/ copy civi db to the new drupal db (delete triggers or not?), 4/ make following changes to civicrm.settings.php (if any are required
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-03T09:30:57.997Z
Answers.Text: The big effort I am having is the moving of Drupal 7 webforms, most of which are integrated with CiviCRM via the excellent webform_civicrm module.  I have now managed, at last to get a repeatable process for conversion and some success at import the old submissions, but it has been tortuous (mainly I'm sure because I never really had to use the migration API).  I'll create a Question/Answer with my findings and see if I can extend my migration and help others with theirs.
Answers.UserDisplayName: ChumKui
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-10T14:43:58.070Z
Answers.LastActivityDate: 2021-12-10T20:21:07.777Z
Answers.LastEditDate: 2021-12-10T20:21:07.777Z
Answers.UserDisplayName: salah-1
Answers.Body: <p>For the Drupal 7 to Drupal 9 part of the upgrade you are best to look for help with the Drupal Community. But sounds like you have this in hand.</p>
  <p>The CiviCRM specific part of the D7 -&gt; D9 the things you'll want to think about are:</p>
  <p><strong>Drupal users</strong>
  If you are migrating drupal users and preserving Drupal User Ids, and drupal roles and user role mappings then you can just copy the civicm_uf_match table. If not then you will want to truncate/update the civicrm_uf_match table each time you bring the civicrm database across - and populate it appropriately.</p>
  <p><strong>CiviCRM &lt;-&gt; Drupal Modules</strong></p>
  <p>CiviCRM Webform Integration - do you have many CiviCRM webforms? How complicated are they? It is possible to migrate CiviCRM webforms using the Drupal  webform_migrate module - however you do need to patch it. However any complicated webforms you might be better rebuilding from scratch. And if you only have a couple you are probably quicker to build them from scratch in D9</p>
  <p>CiviCRM Views - I've not seem any good solutions to automagically migrate views yet. You'll need to rebuild all of these.</p>
  <p>CiviCRM Entity - There is a D9 version of CiviCRM Entity - however I'm not aware of any migrations for this.</p>
  <p><strong>CiviCRM Version and extensions</strong>
  To minimise the chance of problems you are best to keep your CiviCRM version and extension versions in sync between your Drupal 7 and Drupal 9 site. (I'm assuming you will have a period of time where you are testing CiviCRM on a copy of the Drupal 9 site.)</p>
  <p>However as you will only ever be copying the CiviCRM database from Drupal 7 site to Drupal 9 site (at the very least once to get it working to test on and another time during the go live for the Drupal 9 site) you can have more recent versions for your extensions and CiviCRM core on the Drupal 9 site than the Drupal 7 site - but it doesn't work the other way around. Just remember to run the upgrade after you import the database each time and I'd only recommend doing this if you are only jumping a few minor versions of CiviCRM core.</p>
  <p><strong>Installing CiviCRM on Drupal 9</strong></p>
  <p>In terms of the process of installing CiviCRM on a Drupal 9 site:</p>
  <p>The following should be all you need if you are installing the latest version of CiviCRM on a site created from drupal/core-recommended - if you were installing older versions there might be additional configuration required.</p>
  <pre><code>composer config extra.enable-patching true
  composer require civicrm/civicrm-{core,packages,drupal-8}:'~5.42'
  </code></pre>
  <p>More details instructions here <a href="https://docs.civicrm.org/installation/en/latest/drupal8/" rel="nofollow noreferrer">https://docs.civicrm.org/installation/en/latest/drupal8/</a></p>
  <p>Note this includes -&gt;</p>
  <pre><code>composer config minimum-stability dev
  </code></pre>
  <p>which is no longer required - and you are probably best avoiding.</p>
  <p>Make sure you have the correct server requirements - especially php extensions. <a href="https://docs.civicrm.org/installation/en/latest/general/requirements/" rel="nofollow noreferrer">https://docs.civicrm.org/installation/en/latest/general/requirements/</a></p>
  <p><strong>Things to think about</strong></p>
  <p>Ideally I'd recommend using drupal/core-recommended to set up the Drupal 9 project. While CiviCRM might work with other set ups if you can use drupal/core-recommended as a starting point you are eliminating some sources of problems and this is what CiviCRM is tested with so you are less likely to hit problems.</p>
  <p>If you are not starting from drupal/core-recommended I'd recommend setting up a copy of the site your building and attempting to install CiviCRM as soon as possible. With a goal of proving the install will work. At a minimum test an angular page like the System Status Check page (Admin -&gt; Admin Console -&gt; System Status) renders properly, but if you have a lot of extensions you probably want to check they work too.</p>
  <p>If someone is building the Drupal 9 site that is not familiar with CiviCRM you'll want to discuss with them theming requirements for any CiviCRM native pages (i.e. Events/Contribution Pages) if this is something you will want to use.</p>
  <p>Additionally if you are using CiviCRM + webforms especially for contributions you will want to consider this as well.</p>
  <p>You might want to have them working on a site with CiviCRM enabled but not a copy of your database just so their styles work for these pages.</p>
  <p><strong>Run sheet</strong></p>
  <p>The addition of CiviCRM to a D7 to D9 upgrade adds complexity and some additional steps. Make sure you have a good run sheet and testing is your friend.</p>
  <p>You can copy your CiviCRM install from your live Drupal 7 to your Drupal 9 by copying the relevant database tables.</p>
  <p>Before you go live you will want to test with a copy of your live CiviCRM database installed on your Drupal 9 site. Assuming you have a copy of the CiviCRM codebase (with a version greater than or equal to your D7 site) and the same for any extensions then all you will require is to:</p>
  <p>Dump all your CiviCRM tables from your D7 site. These should all be prefixed with civicrm_  (So something like - assuming you have pv installed if not remove that from the pipeline)</p>
  <pre><code> mysqldump --single-transaction --skip-triggers database-name $(mysql -BN -e &quot;select table_name from information_schema.tables where table_schema = 'database-name' and (table_name like 'civicrm_%' or table_name like 'civicrm_log_%' )  | pv | perl -p -e 's#\/\*\!5001[7|3].*?`[^\*]*\*\/##g' | gzip &gt; dumpfile.sql.gz
  </code></pre>
  <p>Where the mysqldump command dumps the database taking the database name and a list of tables returned from the mysql command - which you should test first.
  The pv command is optional - just shows you a progress bar.
  The perl command strips out various things you don't need in the dump that can cause errors - see <a href="https://civicrm.stackexchange.com/questions/619/why-do-i-get-access-denied-you-need-at-least-one-of-the-super-privileges-f">Why do I get &quot;Access denied; you need (at least one of) the SUPER privilege(s) for this operation&quot; when importing a SQL dump to CiviCRM?</a> for more information.
  the gzip command is optional if you are copying between servers you'll want to compress the output.</p>
  <p>There is at least one CiviCRM extension which uses a non standard prefix (not civicrm) - so if you get missing table errors double check that you don't have an extension using a table that isn't prefixed correctly.</p>
  <p>Assuming you have already installed a blank CiviCRM for testing on this site drop all the CiviCRM tables (or database if you have the CiviCRM tables in a different database).</p>
  <p>If you haven't note you can't just copy the civicrm.settings.php file from the D7 install over - there are some differences in paths between the two systems which will probably show as any CiviCRM CSS/JS resources failing to load in the browser.</p>
  <p>Then load the dump file into database you are using for the Drupal 9 site either into the Drupal Database (easy) or a different database (slightly more difficult).</p>
  <p>If the path to your extension directory is different between d7 and d9 which is likely make sure that is set correctly - the easiest way to use the commented setting in civicrm.settings.php. Visit a CiviCRM admin page and ensure you don't get missing extension warnings. if you do you'll need to force a refresh either in the UI via the manage extensions page or using cv.</p>
  <p>Set your outbound mail off and put into staging mode to prevent a cron job from triggering any payments. (Assuming you haven't overridden this in your schedule jobs page - which would be rare, in which case disable the job there).</p>
  <p>Files - you'll also want to copy across any files that CiviCRM manages. If you check your Admin - System Settings -&gt; Directories it will give you a path to look for these in. It might be that you don't have anything to copy. And you might be okay to just do the initial copy and the final copy and leave this step out of any intermediate copies during/for testing.</p>
  <p>If your D7 site CiviCRM version is behind your D9 CiviCRM version run the CiviCRM upgrade.</p>
  <p><strong>Go live</strong></p>
  <p>You'll need to plan in as part of the migration the time taken to switch your CiviCRM database over - and you want to either:</p>
  <ul>
  <li>have the Drupal 7 site in maintenance mode for this period, or</li>
  <li>have a plan to manually copy any updates made in CiviCRM (i.e. unsubscribes, subscribes, payments etc) after you dump the tables to the time you switch over.</li>
  </ul>
  <p>If the people managing your Drupal upgrade are not familiar with CiviCRM you'll want to flag this with them as they will need to build this into their plans.</p>
  <p>If the new D9 site will live on a different server then you will need to think about the DNS propagation time too, decrease your TTL in good time to minimise this.
  You can potentially set up a reverse proxy on one of the servers to eliminate this lag to minimise time in maintenance mode - however if you are okay with more downtime that is an easier solution.</p>
  <p>If possible I'd recommend running a practice of copying your CiviCRM install across immediately before you go live, and after a freeze on any changes to the Drupal site. Build in an additional round of testing. That gives you a chance to get a good time estimate to help with your cut over planning and will hopefully pick up any last minute errors that happen.</p>
  <p><strong>Final Notes</strong></p>
  <p>If you have any custom extensions test them. If you take payments test your payment processor if possible with a live $1 transaction.</p>
  <p>Then enjoy your shiny new Drupal 9 site. And share anything you found about the process here/with the community. With Drupal 7 end of live November 2022, and Drupal 7 still having a plurality of installs by CMS there will be a few people treading this upgrade path this year.</p>
  <p>--</p>
  <p>Postscript:</p>
  <p>Migrating webforms? If only a couple recommend rebuilding but if you want to migrate you could look at using  <a href="https://github.com/fuzionnz/webform_civicrm_migrate" rel="nofollow noreferrer">https://github.com/fuzionnz/webform_civicrm_migrate</a> and <a href="https://github.com/fuzionnz/webform_migrate_plus" rel="nofollow noreferrer">https://github.com/fuzionnz/webform_migrate_plus</a> - definitely backup before using.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-12T22:19:32.507Z
Answers.Text: Hello Luke, looks amazing and details you've shared with is a lot. This definitely will help me a lot going forward. Will update this once I go through things. :)
Answers.UserDisplayName: Tony
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-12T23:02:40.833Z
Answers.Text: I'm pretty sure there will be stuff missing here - but hopefully we can add to this or other answers as we go to get a definitive list.
Answers.UserDisplayName: Luke Stewart
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-13T20:49:38.160Z
Answers.Text: once there is feedback from Tony then this should probably get added to civi documentation
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-16T15:56:39.650Z
Answers.Text: Wow, @LukeStewart this is really wonderful. We need to port lots of this to CiviCRM documentation.
Answers.UserDisplayName: Joe Murray
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-04-28T16:49:08.223Z
Answers.Text: RE the Postsctipt and Drupal Webforms.  I have had an abolsute nightmare getting this to run using various instructions littered over the forums. I have managed to get what loosely could be described as a semi successful import (no civi integration) using a clone of branch webform_migrate_3351844 and will document this with a Question.  This needs proper agreement on the method and documentation given how important Drupal Webform is for many admins.
Answers.UserDisplayName: ChumKui
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-02T02:44:07.400Z
Answers.Text: Hi @ChumKuid webform_civicrm_migrate and webform_migrate_plus are definitely a work in progress. The webform_civicrm maintainers recommended method is to recreate webforms. If this is not practical due to having a lot of webforms you could look at the above. If you do hit issues feel free to ping me (luke-nz) on chat.civicrm.org/ and I might be able to help.
Answers.UserDisplayName: Luke Stewart
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-01-18T20:59:37.327Z
Answers.Text: @Tony have you had a chance to try the above yet - is there any big gaps! Would love some feedback on this from others who have gone through the process before we look at moving it into the documentation.
Answers.UserDisplayName: Luke Stewart
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-01-31T03:10:18.210Z
Answers.Text: Hey @Luke, first of all thanks for the write up and very thorough explanations. This plan you shared works really well. I have followed it thoroughly and did smaller testing every time. I will upload detailed steps from how and what I did, later as I am not very familiar with how to format things properly in this comment section. After CiviCRM migration to D9, I have done CiviCRM upgrade from 5.40.2 -> 5.42.0. Which also worked well too :-) So at this stage I have D9 site with whole CiviCRM migrated.
Answers.UserDisplayName: Tony
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-01-31T03:11:14.510Z
Answers.Text: Next steps is to figure out D9 users vs CiviCRM contacts syncing. Planning to delete sync table from CiviCRM and figure out way to generate Drupal users based on old system.
Answers.UserDisplayName: Tony
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-01-31T03:15:19.987Z
Answers.Text: You should be able to run a Drupal migrate to bring your D7 users over to D9. However from memory that doesn't necessary preserve Drupal User Id especially if there are already users on your D9 system - so you might need to either write a migration plugin to update your uf_match table - or depending on how complicated a set up you have - you might be able to just wipe that table and repopulate it by matching on email.
Answers.UserDisplayName: Luke Stewart
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-01-31T03:19:20.187Z
Answers.Text: If you don't have edit privileges if you add bits in comments and I can update above - but we might be better to start shifting this to  the docs - if you are not familiar with editing there perhaps start with a new issue - otherwise I think we need to set up a new page https://lab.civicrm.org/documentation/docs/sysadmin/-/issues/new?issue%5Bmilestone_id%5D=
Answers.UserDisplayName: Luke Stewart
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-12T00:34:23.340Z
Answers.LastActivityDate: 2023-04-03T03:31:16.227Z
Answers.LastEditDate: 2023-04-03T03:31:16.227Z
Answers.UserDisplayName: Luke Stewart
Body: <p>Hello dear Civi experts,</p>
  <p>I am new to CiviCRM world and have a task at hand to upgrade <strong>CiviCRM 5.40</strong> which integrated to <strong>Drupal 7.82</strong> into <strong>5.42</strong>.</p>
  <p>Then <strong>lift whole CiviCRM</strong> side and integrate to <strong>new Drupal 9 system</strong>, which is getting built at the moment.</p>
  <p>Is it something possible to do? What are the thoughts or considerations in doing above practices?</p>
  <p>Thanks in advance.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-12-10T04:00:11.920Z
Comments.Text: can def. be done. some hints here: https://civicrm.stackexchange.com/questions/39734/upgrade-drupal-7-to-drupal-9
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-12-10T15:25:39.820Z
Comments.Text: Is it Drupal to Drupal or Wordpress to Drupal? i thought i read wordpress somewhere, but can't see that now.
Comments.UserDisplayName: salah-1
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-12-10T20:03:57.240Z
Comments.Text: the Q says they are upgrading from D7 to D9
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-12-12T22:17:50.967Z
Comments.Text: Thanks @petednz-fuzion, will definitely check the link you shared.
Comments.UserDisplayName: Tony
Tags: <upgrade><drupal-9>
Title: Moving existing CiviCRM to new Drupal instance + upgrade to Drupal 9
ThreadText: # Moving existing CiviCRM to new Drupal instance + upgrade to Drupal 9
  
  (Asked by: username_0 on 2021-12-10)
  
  Hello dear Civi experts,
  
  I am new to CiviCRM world and have a task at hand to upgrade **CiviCRM 5.40** which integrated to **Drupal 7.82** into **5.42**.
  
  Then **lift whole CiviCRM** side and integrate to **new Drupal 9 system**, which is getting built at the moment.
  
  Is it something possible to do? What are the thoughts or considerations in doing above practices?
  
  Thanks in advance.
  
  **Tags:** upgrade, drupal-9
  
  > **Comments:**
  > **username_1**: can def. be done. some hints here: https://civicrm.stackexchange.com/questions/39734/upgrade-drupal-7-to-drupal-9  
  > **username_2**: Is it Drupal to Drupal or Wordpress to Drupal? i thought i read wordpress somewhere, but can't see that now.  
  > **username_1**: the Q says they are upgrading from D7 to D9  
  > **username_0**: Thanks @petednz-fuzion, will definitely check the link you shared.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_4 on 2021-12-12. Score: 15 | Accepted answer
  
  For the Drupal 7 to Drupal 9 part of the upgrade you are best to look for help with the Drupal Community. But sounds like you have this in hand.
  The CiviCRM specific part of the D7 -> D9 the things you'll want to think about are:
  Drupal users
  If you are migrating drupal users and preserving Drupal User Ids, and drupal roles and user role mappings then you can just copy the civicm_uf_match table. If not then you will want to truncate/update the civicrm_uf_match table each time you bring the civicrm database across - and populate it appropriately.
  CiviCRM <-> Drupal Modules
  CiviCRM Webform Integration - do you have many CiviCRM webforms? How complicated are they? It is possible to migrate CiviCRM webforms using the Drupal  webform_migrate module - however you do need to patch it. However any complicated webforms you might be better rebuilding from scratch. And if you only have a couple you are probably quicker to build them from scratch in D9
  CiviCRM Views - I've not seem any good solutions to automagically migrate views yet. You'll need to rebuild all of these.
  CiviCRM Entity - There is a D9 version of CiviCRM Entity - however I'm not aware of any migrations for this.
  CiviCRM Version and extensions
  To minimise the chance of problems you are best to keep your CiviCRM version and extension versions in sync between your Drupal 7 and Drupal 9 site. (I'm assuming you will have a period of time where you are testing CiviCRM on a copy of the Drupal 9 site.)
  However as you will only ever be copying the CiviCRM database from Drupal 7 site to Drupal 9 site (at the very least once to get it working to test on and another time during the go live for the Drupal 9 site) you can have more recent versions for your extensions and CiviCRM core on the Drupal 9 site than the Drupal 7 site - but it doesn't work the other way around. Just remember to run the upgrade after you import the database each time and I'd only recommend doing this if you are only jumping a few minor versions of CiviCRM core.
  Installing CiviCRM on Drupal 9
  In terms of the process of installing CiviCRM on a Drupal 9 site:
  The following should be all you need if you are installing the latest version of CiviCRM on a site created from drupal/core-recommended - if you were installing older versions there might be additional configuration required.
  composer config extra.enable-patching true
  composer require civicrm/civicrm-{core,packages,drupal-8}:'~5.42'
  
  More details instructions here https://docs.civicrm.org/installation/en/latest/drupal8/
  Note this includes ->
  composer config minimum-stability dev
  
  which is no longer required - and you are probably best avoiding.
  Make sure you have the correct server requirements - especially php extensions. https://docs.civicrm.org/installation/en/latest/general/requirements/
  Things to think about
  Ideally I'd recommend using drupal/core-recommended to set up the Drupal 9 project. While CiviCRM might work with other set ups if you can use drupal/core-recommended as a starting point you are eliminating some sources of problems and this is what CiviCRM is tested with so you are less likely to hit problems.
  If you are not starting from drupal/core-recommended I'd recommend setting up a copy of the site your building and attempting to install CiviCRM as soon as possible. With a goal of proving the install will work. At a minimum test an angular page like the System Status Check page (Admin -> Admin Console -> System Status) renders properly, but if you have a lot of extensions you probably want to check they work too.
  If someone is building the Drupal 9 site that is not familiar with CiviCRM you'll want to discuss with them theming requirements for any CiviCRM native pages (i.e. Events/Contribution Pages) if this is something you will want to use.
  Additionally if you are using CiviCRM + webforms especially for contributions you will want to consider this as well.
  You might want to have them working on a site with CiviCRM enabled but not a copy of your database just so their styles work for these pages.
  Run sheet
  The addition of CiviCRM to a D7 to D9 upgrade adds complexity and some additional steps. Make sure you have a good run sheet and testing is your friend.
  You can copy your CiviCRM install from your live Drupal 7 to your Drupal 9 by copying the relevant database tables.
  Before you go live you will want to test with a copy of your live CiviCRM database installed on your Drupal 9 site. Assuming you have a copy of the CiviCRM codebase (with a version greater than or equal to your D7 site) and the same for any extensions then all you will require is to:
  Dump all your CiviCRM tables from your D7 site. These should all be prefixed with civicrm_  (So something like - assuming you have pv installed if not remove that from the pipeline)
   mysqldump --single-transaction --skip-triggers database-name $(mysql -BN -e "select table_name from information_schema.tables where table_schema = 'database-name' and (table_name like 'civicrm_%' or table_name like 'civicrm_log_%' )  | pv | perl -p -e 's#\/\*\!5001[7|3].*?`[^\*]*\*\/##g' | gzip > dumpfile.sql.gz
  
  Where the mysqldump command dumps the database taking the database name and a list of tables returned from the mysql command - which you should test first.
  The pv command is optional - just shows you a progress bar.
  The perl command strips out various things you don't need in the dump that can cause errors - see Why do I get "Access denied; you need (at least one of) the SUPER privilege(s) for this operation" when importing a SQL dump to CiviCRM? for more information.
  the gzip command is optional if you are copying between servers you'll want to compress the output.
  There is at least one CiviCRM extension which uses a non standard prefix (not civicrm) - so if you get missing table errors double check that you don't have an extension using a table that isn't prefixed correctly.
  Assuming you have already installed a blank CiviCRM for testing on this site drop all the CiviCRM tables (or database if you have the CiviCRM tables in a different database).
  If you haven't note you can't just copy the civicrm.settings.php file from the D7 install over - there are some differences in paths between the two systems which will probably show as any CiviCRM CSS/JS resources failing to load in the browser.
  Then load the dump file into database you are using for the Drupal 9 site either into the Drupal Database (easy) or a different database (slightly more difficult).
  If the path to your extension directory is different between d7 and d9 which is likely make sure that is set correctly - the easiest way to use the commented setting in civicrm.settings.php. Visit a CiviCRM admin page and ensure you don't get missing extension warnings. if you do you'll need to force a refresh either in the UI via the manage extensions page or using cv.
  Set your outbound mail off and put into staging mode to prevent a cron job from triggering any payments. (Assuming you haven't overridden this in your schedule jobs page - which would be rare, in which case disable the job there).
  Files - you'll also want to copy across any files that CiviCRM manages. If you check your Admin - System Settings -> Directories it will give you a path to look for these in. It might be that you don't have anything to copy. And you might be okay to just do the initial copy and the final copy and leave this step out of any intermediate copies during/for testing.
  If your D7 site CiviCRM version is behind your D9 CiviCRM version run the CiviCRM upgrade.
  Go live
  You'll need to plan in as part of the migration the time taken to switch your CiviCRM database over - and you want to either:
  
  have the Drupal 7 site in maintenance mode for this period, or
  have a plan to manually copy any updates made in CiviCRM (i.e. unsubscribes, subscribes, payments etc) after you dump the tables to the time you switch over.
  
  If the people managing your Drupal upgrade are not familiar with CiviCRM you'll want to flag this with them as they will need to build this into their plans.
  If the new D9 site will live on a different server then you will need to think about the DNS propagation time too, decrease your TTL in good time to minimise this.
  You can potentially set up a reverse proxy on one of the servers to eliminate this lag to minimise time in maintenance mode - however if you are okay with more downtime that is an easier solution.
  If possible I'd recommend running a practice of copying your CiviCRM install across immediately before you go live, and after a freeze on any changes to the Drupal site. Build in an additional round of testing. That gives you a chance to get a good time estimate to help with your cut over planning and will hopefully pick up any last minute errors that happen.
  Final Notes
  If you have any custom extensions test them. If you take payments test your payment processor if possible with a live $1 transaction.
  Then enjoy your shiny new Drupal 9 site. And share anything you found about the process here/with the community. With Drupal 7 end of live November 2022, and Drupal 7 still having a plurality of installs by CMS there will be a few people treading this upgrade path this year.
  --
  Postscript:
  Migrating webforms? If only a couple recommend rebuilding but if you want to migrate you could look at using  https://github.com/fuzionnz/webform_civicrm_migrate and https://github.com/fuzionnz/webform_migrate_plus - definitely backup before using.
  
  > **Comments:**
  > **username_0**: Hello Luke, looks amazing and details you've shared with is a lot. This definitely will help me a lot going forward. Will update this once I go through things. :)  
  > **username_4**: I'm pretty sure there will be stuff missing here - but hopefully we can add to this or other answers as we go to get a definitive list.  
  > **username_1**: once there is feedback from username_0 then this should probably get added to civi documentation  
  > **username_5**: Wow, @LukeStewart this is really wonderful. We need to port lots of this to CiviCRM documentation.  
  > **username_4**: @username_0 have you had a chance to try the above yet - is there any big gaps! Would love some feedback on this from others who have gone through the process before we look at moving it into the documentation.  
  > **username_0**: Hey @Luke, first of all thanks for the write up and very thorough explanations. This plan you shared works really well. I have followed it thoroughly and did smaller testing every time. I will upload detailed steps from how and what I did, later as I am not very familiar with how to format things properly in this comment section. After CiviCRM migration to D9, I have done CiviCRM upgrade from 5.40.2 -> 5.42.0. Which also worked well too :-) So at this stage I have D9 site with whole CiviCRM migrated.  
  > **username_0**: Next steps is to figure out D9 users vs CiviCRM contacts syncing. Planning to delete sync table from CiviCRM and figure out way to generate Drupal users based on old system.  
  > **username_4**: You should be able to run a Drupal migrate to bring your D7 users over to D9. However from memory that doesn't necessary preserve Drupal User Id especially if there are already users on your D9 system - so you might need to either write a migration plugin to update your uf_match table - or depending on how complicated a set up you have - you might be able to just wipe that table and repopulate it by matching on email.  
  > **username_4**: If you don't have edit privileges if you add bits in comments and I can update above - but we might be better to start shifting this to  the docs - if you are not familiar with editing there perhaps start with a new issue - otherwise I think we need to set up a new page https://lab.civicrm.org/documentation/docs/sysadmin/-/issues/new?issue%5Bmilestone_id%5D=  
  > **username_3**: RE the Postsctipt and Drupal Webforms.  I have had an abolsute nightmare getting this to run using various instructions littered over the forums. I have managed to get what loosely could be described as a semi successful import (no civi integration) using a clone of branch webform_migrate_3351844 and will document this with a Question.  This needs proper agreement on the method and documentation given how important Drupal Webform is for many admins.  
  > **username_4**: Hi @username_3d webform_civicrm_migrate and webform_migrate_plus are definitely a work in progress. The webform_civicrm maintainers recommended method is to recreate webforms. If this is not practical due to having a lot of webforms you could look at the above. If you do hit issues feel free to ping me (luke-nz) on chat.civicrm.org/ and I might be able to help.  
  
  ---
  
  ### Answer by username_2 on 2021-12-10. Score: 1
  
  I have setup CiviCRM with drupal 8 and 9 few times and here is how i would do it.
  
  **Prep**
  
  1- Check your machine supports at-least the minimum PHP and MySQL versions
  <https://docs.civicrm.org/installation/en/latest/general/requirements/>
  
  2-First Install Drupal 9 and have it working 100%.
  
  3-Then use the cv command line tool (my preference) to install civi, specially if you want to install civi in separate database than the Drupal one and check this link for other requirements.
  <https://docs.civicrm.org/installation/en/latest/drupal8/>
  
  4 - move over your modules or other dependency stuff such as composer
  
  5- Fix whatever issues that popup etc
  
  **For: Drupal 9:**
  
  1- Note that Drupal 9 has higher PHP, Apache and MySQL requirement, so check below link to meet those. My personal preference is since Drupal 10 isn't too far and it will require PHP 8, to just go straight to PHP 8 (supported by latest Civi and Drupal 9).
  
  <https://www.drupal.org/docs/understanding-drupal/how-drupal-9-was-made-and-what-is-included/environment-requirements-of-drupal-9>
  
  <https://www.drupal.org/docs/system-requirements/php-requirements>
  
  2 - Other steps will be similar to above one. You would install Drupal first and get it working, then copy your modules that support Drupal 9 and fix comparability issues.
  
  3 - Then you would install Civi 5.4.2 or latest version that supports Drupal 9.
  
  4 - Consult with below links if the official install links for Drupal 9 don't work for Civi.
  
  [What is the status of CiviCRM working with Drupal 9?](https://civicrm.stackexchange.com/questions/35746/what-is-the-status-of-civicrm-working-with-drupal-9)
  
  [Can't install civiCRM with drupal 9.2.7](https://civicrm.stackexchange.com/questions/40620/cant-install-civicrm-with-drupal-9-2-7)
  
  * my recommendation is if your final destination is Drupal 9, just go straight to that and save time, unless you have other requirements that need Drupal 7.8.2
  
  Good luck.
  
  > **Comments:**
  > **username_1**: I don't think this answers the problem. as i read it username_0 has civi on d7 and wants to move it to d9  
  > **username_2**: Updated the answer!  
  > **username_1**: i think your answer is missing the main point. i may be wrong. but if you already have civicrm on d7, and you build a d9 site, and then you want to move the civicrm from the d7 site to the d9 site, what steps do you need to take eg are they 1/ update civi to latest on d7 2/ install same version via composer on d9 site, 3/ copy civi db to the new drupal db (delete triggers or not?), 4/ make following changes to civicrm.settings.php (if any are required  
  > **username_3**: The big effort I am having is the moving of Drupal 7 webforms, most of which are integrated with CiviCRM via the excellent webform_civicrm module.  I have now managed, at last to get a repeatable process for conversion and some success at import the old submissions, but it has been tortuous (mainly I'm sure because I never really had to use the migration API).  I'll create a Question/Answer with my findings and see if I can extend my migration and help others with theirs.  
  
  ---
  
  