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

Additional to-file and from-file sub commands #96

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

timclifford
Copy link
Contributor

@timclifford timclifford commented Sep 6, 2023

As per #80 - this adds two new sub-commands under sync: to-file and from-file. This enables a user to directly import resources from a dump file into a given target environment and it also allows a user to run only a resource dump to file.

$ lagoon-sync sync to-file --help

Use Lagoon-Sync to sync an external environments resources with the local environment

Usage:
  lagoon-sync sync [mariadb|files|mongodb|postgres|etc.] [flags]
  lagoon-sync sync [command]

Available Commands:
  from-file   Sync from a file
  to-file     Sync to a file

Flags:
      --dry-run                          Don't run the commands, just preview what will be run
  -h, --help                             help for sync
      --no-interaction                   Disallow interaction
  -p, --project-name string              The Lagoon project name of the remote system
  -r, --rsync-args string                Pass through arguments to change the behaviour of rsync (default "--omit-dir-times --no-perms --no-group --no-owner --chmod=ugo=rwX --recursive --compress")
  -s, --service-name string              The service name (default is 'cli'
      --skip-source-cleanup              Don't clean up any of the files generated on the source
      --skip-source-run                  Don't run any ops on the source
      --skip-target-cleanup              Don't clean up any of the files generated on the target
      --skip-target-import               This will skip the import step on the target, in combination with 'no-target-cleanup' this essentially produces a resource dump
  -e, --source-environment-name string   The Lagoon environment name of the source system
  -H, --ssh-host string                  Specify your lagoon ssh host, defaults to 'ssh.lagoon.amazeeio.cloud' (default "ssh.lagoon.amazeeio.cloud")
  -i, --ssh-key string                   Specify path to a specific SSH key to use for authentication
  -P, --ssh-port string                  Specify your ssh port, defaults to '32222' (default "32222")
  -t, --target-environment-name string   The target environment name (defaults to local)
  -f, --transfer-resource-name string    The name of the temporary file to be used to transfer generated resources (db dumps, etc) - random /tmp file otherwise
      --verbose                          Run ssh commands in verbose (useful for debugging)

Global Flags:
      --config string   Path to the file used to set lagoon-sync configuration
      --show-debug      Shows debug information

Use "lagoon-sync sync [command] --help" for more information about a command.

The default syncher is mariadb so you can omit it as as argument after sync.

Examples:

This to-file example will perform a database dump of the dev environment.

lagoon-sync sync mariadb to-file -f dev-db-dump.sql.gz -p example-project -e dev --dry-run

This from-file example will import a local database dump into the dev environment of the project.

lagoon-sync sync mariadb from-file -f local-db-dump.sql.gz -p example-project -t dev --dry-run

@tobybellwood
Copy link
Member

tobybellwood commented Sep 30, 2024

The ability to sync a single (or regex!) files either way would be useful for some new use cases (specifically syncing a composer.{json|lock} file from prod>local
Bonus points if there was a way to specify them as a built-in option in the config for easy re-use

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

Successfully merging this pull request may close these issues.

2 participants