Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a flag to specify the target filename for a sql dump #93

Open
KeyboardCowboy opened this issue Aug 7, 2023 · 0 comments
Open

Add a flag to specify the target filename for a sql dump #93

KeyboardCowboy opened this issue Aug 7, 2023 · 0 comments
Assignees

Comments

@KeyboardCowboy
Copy link

Motivation

When using the sync command to retrieve a database from a Lagoon environment, I'd like to be able to specify the destination filename so I can reference it specifically on my server.

I'm currently working on an integration between Lullabot's Tugboat QA system and Lagoon, and the flexibility to specify the target name would allow me to use the Tugboat config file to do the import needing to use a wildcard to search for a filename. I imagine this could also be useful if you are extracting databases from multiple environments.

Current Behavior

Running the following command:

lagoon-sync sync mariadb -e "${LAGOON_PROD_ENV}" --skip-target-cleanup=true --skip-target-import=true

results in a file like this:

/tmp/lagoon_sync_mariadb_1691429815236837058.sql.gz

This doesn't specify the environment and the timestamp doesn't allow me to target this file specifically in order to script an import on my service.

Desired Behavior

I'd like to use a flag like this:

lagoon-sync sync mariadb -e "${LAGOON_PROD_ENV}" --target-file="lagoon-${LAGOON_PROD_ENV}--latest.sql.gz" --skip-target-cleanup=true --skip-target-import=true

Why not use Lagoon sync to import the db?

The .lagoon.yml file allows me to override the database config as so:

# https://github.com/uselagoon/lagoon-sync/tree/v0.7.1
lagoon-sync:
  mariadb:
    config:
      hostname: "${MARIADB_HOST:-mariadb}"
      username: "${MARIADB_USERNAME:-drupal}"
      password: "${MARIADB_PASSWORD:-drupal}"
      port: "${MARIADB_PORT:-3306}"
      database: "${MARIADB_DATABASE:-drupal}"
  files:
    config:
      sync-directory: "/app/web/sites/default/files"
  drupalconfig:
    config:
      syncpath: "./config/sync"

But then assumes that the source and target services use the same credentials. Tugboat has predefined credentials that do not match, so the sync fails on import. It's simpler and more flexible for us to get that dumpfile, run our own import, and do the cleanup ourselves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants