DEV Community

Alanna Burke for Lagoon

Posted on

Lagoon CLI Cheat Sheet

If you’re a Lagoon user, you’re probably using the Lagoon CLI (if not - check it out!). We’ve got a cheat sheet of useful commands to help you get the most out of Lagoon.

Confirm it’s working

# Test it out
lagoon login
Enter fullscreen mode Exit fullscreen mode
# if using something other than main “id_rsa” use the below to point to private key
lagoon login -i ~/.ssh/path-to-rsa
Enter fullscreen mode Exit fullscreen mode
# Use this command to see who you are logged in as
lagoon whoami
Enter fullscreen mode Exit fullscreen mode

Update project settings

# update project branches
lagoon update project -p [project-name] -b "^([branch-1]|[branch-2])$" 
Enter fullscreen mode Exit fullscreen mode
# update project repo
lagoon update project -p [project-name] -g git@github.com:[repo-name]/[project-name].git 
Enter fullscreen mode Exit fullscreen mode
# update which branch is production
lagoon update project -p [project-name] -E [branch-name]
Enter fullscreen mode Exit fullscreen mode
# set “pull requests enabled” to true for project
lagoon update project -p [project-name] -m true
Enter fullscreen mode Exit fullscreen mode

SSH

# SSH access is for debugging purposes. Any changes made to files will be lost the next time the container restarts. 
# SSH into Lagoon remote
lagoon ssh -p [project-name] -e [environment-name]
Enter fullscreen mode Exit fullscreen mode

Add / Delete Envs

# Manually delete an environment from Lagoon (will not delete the branch from your repo)
lagoon delete environment -p [project-name] -e [environment-name]
# You can also do this through the UI; there is a button on the dashboard which allows you to manually delete envs.

# To add env: 
  # Make sure the branches are set correctly on your project
  # Create branch
  # Make your first commit on the branch and push to repo
  # If you have your branches correctly configured on Lagoon, this should trigger an automatic deployment of the environment.
Enter fullscreen mode Exit fullscreen mode

Variables

# List variables for a project or environment (alias: v)
lagoon list variables

# Add or update a variable to an environment or project
lagoon add variable

# Add or update a variable to an environment or project
lagoon update variable 

# Delete a variable from an environment
lagoon delete variable
Enter fullscreen mode Exit fullscreen mode

List groups, projects, users

# List groups you have access to (alias: g)
lagoon list groups

# List projects in a group (alias: gp)
lagoon list group-projects

# List all users in groups
lagoon list group-users

# List a single users groups and roles
lagoon list user-groups

# List all projects you have access to (alias: p)
lagoon list projects
Enter fullscreen mode Exit fullscreen mode

Backups, archives, cache clearing

# Get a backup download link
lagoon get backup

# Run a drush archive dump on an environment
lagoon run drush-archivedump

Enter fullscreen mode Exit fullscreen mode
# Run a drush cache clear on an environment
lagoon run drush-cacheclear

# Run a drush sql dump on an environment
lagoon run drush-sqldump
Enter fullscreen mode Exit fullscreen mode

You can check out the Lagoon CLI docs here to see a list of all commands and options: https://uselagoon.github.io/lagoon-cli/.

And don’t forget our 2024 Community Survey! Let us know how we can best serve the Lagoon community.

Top comments (0)