Often I want to "reinstall" a site from scratch for various reasons. This is especially true with DevShop, which is more of a development and testing platform, we need to "reinstall" all the time.

I've acquired some of that "Aegir Tribal Knowledge", so I know how to do this in a few steps:

  1. Delete a site's site_path.
  2. Run drush @sitename provision-install or drush @hostmaster hosting-task 123 --force.
  3. Run a verify task in the front end to update any information.
  4. Cry a tear as I remember there is now an "orphan" database that I'll have to delete manually, or never.

DevShop's method of "rebuilding" an environment database was "provision_sync" project, which is shaky at best. It often fails.

In devshop, we now only use "Install" tasks, even if we are "cloning" another environment. This will make it easy to "reinstall", if we can just automatically remove the database and sites folder before the install kicks off again.

I've managed to make this work with this patch and branch.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jon Pugh created an issue. See original summary.

  • Jon Pugh committed a064482 on 2836185-force-reinstall
    Issue #2836185: Allow "force-reinstall" drush option for "provision-...
Jon Pugh’s picture

Jon Pugh’s picture

Issue tags: +devshop patches

I'm including this patch in the next release of devshop.

It works!

  • Jon Pugh committed 80a11d5 on 2836185-force-reinstall
    Issue #2836185: Allow "force-reinstall" drush option for "provision-...
Jon Pugh’s picture

FileSize
1.53 KB

Sorry about the bad patch. New branch pushed with just these changes.

Jon Pugh’s picture

About this...

+      // Load the current database name from drushrc.php.
+      // I cannot find another way to find the current db_name!
+      require_once(d()->site_path . '/drushrc.php');
+      $old_db_name = $options['db_name'];

I tried 6 ways from sunday to get the database name somehow. All null.

  • global $databases;
  • global $db_url;
  • drush_get_option('db_name');

The problem is that the credentials aren't loaded until after drush validation hook, and when they are, they load a new database name.

We should really consider making it easier to figure out what database the site is using!

Jon Pugh’s picture

Status: Needs review » Closed (duplicate)

Ergonlogic was kind enough to point me to https://www.drupal.org/project/hosting_reinstall and https://www.drupal.org/project/hosting_dev.

I'm going to propose to put hosting_reinstall into hosting_tasks_extras in #2838431: Add Hosting Site Reinstall to hosting_tasks_extra

Jon Pugh’s picture

Actually I think this patch still has merit. I had problems with running the reinstall. This would be a simple backend, CLI API only addition, for now. Creating a UI for this is secondary.

Jon Pugh’s picture

Status: Closed (duplicate) » Needs review

See branch 2836185-force-reinstall

I'm still including this in devshop.

  • helmo committed f4deaea on 2836185-force-reinstall
    Issue #2836185 by Jon Pugh: Document the force-reinstall option.
    
helmo’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
2.08 KB

Just tested and seems to work fine ... I added a line to document the option on the branch.

I'd say RTBC ...

What if hosting_reinstall we're just a frontend for this --force-reinstall option.

colan’s picture

What if hosting_reinstall we're just a frontend for this --force-reinstall option.

Might be overkill if that's all it's doing. Given that the back-end is in core, why not put the front-end in core too?

  • Jon Pugh committed 80a11d5 on 7.x-3.x
    Issue #2836185: Allow "force-reinstall" drush option for "provision-...
  • helmo committed f4deaea on 7.x-3.x
    Issue #2836185 by Jon Pugh: Document the force-reinstall option.
    
helmo’s picture

Status: Reviewed & tested by the community » Fixed

Merged

One reason to not have the ui in core would the that it's a 'risky' one for new users to have available by default. But I'm open to suggestions.

colan’s picture

Hosting Tasks Extra then?

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

colan’s picture

Status: Closed (fixed) » Needs work

Let's figure out where to create a ticket for the front end task, and then let's close this one.

  • Jon Pugh committed 3979e67 on 7.x-3.x
    Revert "Issue #2836185: Allow "force-reinstall" drush option for "...
  • Jon Pugh committed a064482 on 7.x-3.x
    Issue #2836185: Allow "force-reinstall" drush option for "provision-...

  • Jon Pugh committed 3979e67 on 7.x-4.x
    Revert "Issue #2836185: Allow "force-reinstall" drush option for "...
  • Jon Pugh committed 80a11d5 on 7.x-4.x
    Issue #2836185: Allow "force-reinstall" drush option for "provision-...
  • Jon Pugh committed a064482 on 7.x-4.x
    Issue #2836185: Allow "force-reinstall" drush option for "provision-...
  • helmo committed f4deaea on 7.x-4.x
    Issue #2836185 by Jon Pugh: Document the force-reinstall option.
    

  • Jon Pugh committed 3979e67 on 2836185-force-reinstall
    Revert "Issue #2836185: Allow "force-reinstall" drush option for "...
  • Jon Pugh committed a064482 on 2836185-force-reinstall
    Issue #2836185: Allow "force-reinstall" drush option for "provision-...
  • Jon Pugh committed 675fe3f on 2836185-force-reinstall
    Issue #2836185 by Jon Pugh, helmo: Allow "force-reinstall" drush option...
Jon Pugh’s picture

Fixed a problem when trying to re-run install tasks for sites that failed.

Jon Pugh’s picture

Status: Needs work » Needs review
Jon Pugh’s picture

helmo’s picture

Status: Needs review » Reviewed & tested by the community

good catch

  • Jon Pugh committed 70702fa on 7.x-3.x
    Issue #2836185 by Jon Pugh, helmo: Allow "force-reinstall" drush option...
Jon Pugh’s picture

Status: Reviewed & tested by the community » Fixed

Merged.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.