Answers for teams moving to Stagecoach from a managed Drupal host such as Acquia or Pantheon. No Kubernetes or systems administration experience is assumed.
The basics
The basics
What is Stagecoach?
Stagecoach gives you the dev, stage and production workflow you know from Acquia or Pantheon, on servers you own. You deploy code, copy databases and take backups from your Drupal admin or from Drush, and Stagecoach carries out the work on your infrastructure.
Do I need to know Kubernetes?
No. Kubernetes is the industry-standard system for running applications on a group of servers, and Stagecoach uses it behind the scenes. You run one setup command when you connect your servers; after that, everyday work happens in Drupal. A few emergency procedures on this page use the kubectl command, and we give each one in full, ready to copy.
What is a cluster, and where do I get one?
A cluster is a group of one or more servers that Kubernetes manages as a single unit. Most cloud providers sell them ready-made: DigitalOcean (DOKS), AWS (EKS), Google Cloud (GKE), Azure (AKS), or Hetzner with k3s. When you create one, the provider gives you a credentials file, often called a kubeconfig. Keep it safe: it is the key to your cluster, and the emergency commands below need it.
How do Stagecoach environments compare to Acquia or Pantheon?
They work the same way. Pantheon's Dev, Test and Live, or Acquia's Dev, Stage and Prod, correspond to Stagecoach's dev, stage and prod. Code moves up, from dev towards production. Databases and files move down, from production towards dev. Production is never overwritten by a copy from a lower environment.
Who hosts my site?
You do, on the cluster you connect. Your code, database and files stay in your cloud account. A small agent in your cluster connects out to api.stagecoach.sh to report status, so you do not need to open any inbound firewall ports.
Day to day
Day to day
How do I deploy code?
Open the dashboard at /admin/stage_coach and drag a code cell onto the environment you want to update, or run drush stagecoach:deploy stage --release=v2.1.0. Each deploy takes a database snapshot, rolls out the new code, then runs database updates and configuration import, the equivalent of drush updb and drush cim. Production deploys ask you to type the environment name to confirm.
Will my site go down during a deploy?
Not for the code rollout: Stagecoach starts the new version before retiring the old one. While database updates run, the site shows Drupal's standard maintenance page, as it would on Acquia or Pantheon. It returns to normal as soon as the updates finish.
How do I copy the production database to dev or stage?
Use a copy-down: drush stagecoach:copy-down prod stage, or drag the database cell from production onto a lower environment in the dashboard. Stagecoach sanitizes the copy on arrival, so customer email addresses and passwords do not end up in your test environments.
Are my databases backed up?
Every deploy takes a snapshot of the database first. You can also take one at any time with drush stagecoach:snapshot prod, list them with drush stagecoach:snapshots prod, and restore one with drush stagecoach:restore prod <ID>. We recommend a snapshot before any risky manual change.
Can I still use Drush?
Yes. Drush works as it always has, and the stage_coach module adds stagecoach:* commands for deploys, copy-downs, snapshots, rollbacks and history. Run drush list --filter=stagecoach to see them all.
How do I know who changed what?
Every operation is recorded under the Drupal user who started it. Run drush stagecoach:history or open the dashboard to see what ran, who ran it, and how it turned out. Only one operation runs at a time, so two people cannot deploy over each other.
A deploy failed and my site is stuck on the maintenance page. Is that a bug?
No, it is a safeguard. If database updates or configuration import fail partway, Stagecoach leaves the site in maintenance mode rather than serve pages from a half-updated database. Run drush stagecoach:history to see which step failed, then either fix the problem and deploy again, or roll back as described in the next answer.
When things go wrong
My production site is showing 500 errors or is down. What should I do?
Stay calm and work through the steps below in order. In most cases, rolling back the last deploy restores service within a few minutes.
Why a rollback works even when your site is broken: rollbacks are carried out by the Stagecoach server, not by your Drupal site. Your broken production site does not need to be working for a rollback of it to succeed. You can issue it from any working environment, such as stage.
-
Find out what changed
Check /status for a Stagecoach incident. Then, from your stage site, check whether production was deployed recently:
drush stagecoach:history --limit=5If production shows a maintenance page rather than an error, see the previous answer: a deploy stopped partway on purpose.
-
If the problem started after a deploy, roll back
This is the fastest fix. From your stage site, or from production's Drush if it still works:
drush stagecoach:rollback prodThis returns production to the code it ran before the last deploy and leaves the database as it is. If that deploy ran database updates, the old code may not work with the updated database. In that case, roll back the data too, which restores the snapshot taken just before the deploy:
drush stagecoach:rollback prod --with-dataBe aware:
--with-datadiscards content created on production since that deploy, such as new nodes, orders or form submissions. Use it only when a code-only rollback has not fixed the site. -
If nothing was deployed, use Drush to investigate
Drush often works when web pages do not, because it does not go through the web server. Read the most recent errors and rebuild caches, which clears many 500 errors on its own:
drush watchdog:show --severity=Error --count=20 drush cache:rebuildIf the database itself is damaged, for example after a bad bulk edit or migration, restore a snapshot:
drush stagecoach:snapshots prod drush stagecoach:restore prod <ID>If Drush on production fails with a fatal error, the code or database is too broken for Drush to start. Roll back from stage, as in step 2.
-
Break glass: if Drush is unavailable everywhere
If no Drupal environment can run Drush, you can trigger the same rollback directly on the Stagecoach server in your cluster. These commands need
kubectland the credentials file from your cloud provider. They bypass Drupal entirely, and the rollback is still recorded in your history.First, display the settings your Stagecoach server runs with:
kubectl -n stage-coach get deployment stage-coach \ -o jsonpath='{.spec.template.spec.containers[0].args}'Then run the rollback, repeating the
-db,-workloadand-containervalues from that output:kubectl -n stage-coach exec deploy/stage-coach -- \ /stage-coach rollback -env prod \ -db=/data/stage-coach.db -workload=drupal -container=drupalAdd
-with-datato also restore the pre-deploy snapshot, with the same caution as in step 2. -
Last resort: if Stagecoach itself is unavailable
Kubernetes keeps a record of the versions it has run, and can return to the previous one without Stagecoach. Replace
<prod-namespace>with your production namespace, which you chose when you registered the environment:kubectl -n <prod-namespace> rollout history deployment/drupal kubectl -n <prod-namespace> rollout undo deployment/drupal kubectl -n <prod-namespace> rollout status deployment/drupalThis restores the previous code only. It does not touch the database, and Stagecoach is not told about it, so let us know once the site is back and we will help you bring the records in line. If an earlier rollback has already run, "previous" may be the broken version: check the history output first.
-
Afterwards
Fix the problem on dev or stage, test it there, then deploy again. If you needed step 4 or 5, or would like help at any point, contact support. Tell us what was deployed, when the errors started, and which steps you took.
Where can I get help?
Check /status for incidents, then contact support or email [email protected]. Report bugs in the Drupal module in its issue queue.