Lagoon CLI Cheat Sheet
Alanna Burke
Posted on February 23, 2024
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
# if using something other than main “id_rsa” use the below to point to private key
lagoon login -i ~/.ssh/path-to-rsa
# Use this command to see who you are logged in as
lagoon whoami
Update project settings
# update project branches
lagoon update project -p [project-name] -b "^([branch-1]|[branch-2])$"
# update project repo
lagoon update project -p [project-name] -g git@github.com:[repo-name]/[project-name].git
# update which branch is production
lagoon update project -p [project-name] -E [branch-name]
# set “pull requests enabled” to true for project
lagoon update project -p [project-name] -m true
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]
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.
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
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
Backups, archives, cache clearing
# Get a backup download link
lagoon get backup
# Run a drush archive dump on an environment
lagoon run drush-archivedump
# Run a drush cache clear on an environment
lagoon run drush-cacheclear
# Run a drush sql dump on an environment
lagoon run drush-sqldump
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.
💖 💪 🙅 🚩
Alanna Burke
Posted on February 23, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.