lando / platformsh

The Official Platform.sh Lando Plugin
https://docs.lando.dev/platformsh
GNU General Public License v3.0
6 stars 4 forks source link

Can't use pipe with drush when importing a local database #144

Closed ptmkenny closed 2 years ago

ptmkenny commented 2 years ago

PlatformSH Drupal 9.

lando.yml

tooling:
  import-database:
    service: drupal
    cmd:
      - drush sql:drop -y
      - gunzip -c /app/backups/local_backups/dbdump_platformsh.sql.gz | drush sql:cli

What happens

SQL tables are dropped. Database import fails with this error:

The appDir variable is not defined. Are you sure you're running on Platform.sh?

What should happen

SQL tables are dropped. Database import succeeds.

Additional info

Manually inputting the commands without using .lando.yml works:

lando ssh
gunzip -c /app/backups/local_backups/dbdump_platformsh.sql.gz | drush sql:cli

So it seems the problem is in how the commands are parsed in .lando.yml (or I am making a mistake in the .lando.yml config).

reynoldsalec commented 2 years ago

Replicated the error; that's being thrown by something in the Platform.sh config reader I think...not really clear on why the pipe would cause that.

In any case, probably the best workaround is to simply unzip the file then run drush sql:cli to import it as separate steps:

tooling:
  import-database:
    service: drupal
    cmd:
      - drush sql:drop -y
      - gunzip /app/backups/local_backups/dbdump_platformsh.sql.gz
      - drush sql:cli < /app/backups/local_backups/dbdump_platformsh.sql

That worked fine for me.