Skip to content

Instantly share code, notes, and snippets.

@laryn
Last active January 2, 2023 18:42
Show Gist options
  • Select an option

  • Save laryn/3746763cd10ed3be4f652c4c3670acfd to your computer and use it in GitHub Desktop.

Select an option

Save laryn/3746763cd10ed3be4f652c4c3670acfd to your computer and use it in GitHub Desktop.
Opinionated Backdrop + XDebug Lando sandbox configuration file
name: sandbox
# Use existing Backdrop recipe, then customise below.
recipe: backdrop
config:
# Where Backdrop resides, relative to this file.
webroot: www
# Prefer MariaDB over MySQL.
database: mariadb
services:
# Install phpMyAdmin.
phpmyadmin:
type: phpmyadmin
# Link it to the default database service (see `lando info`).
hosts:
- database
tooling:
# Allow Drush to be run from any directory.
drush:
service: appserver
cmd: drush --root=/app/www --uri=https://sandbox.lndo.site
# Create a snapshot of the site.
snapshot:
service: appserver
cmd:
- mysqldump --add-drop-database -Bu root -h database -P 3306 backdrop > /app/backdrop.sql
- gzip -f /app/backdrop.sql
- cd /app/www/files/config_* && tar -czf /app/config.tar.gz active
- echo 'Snapshot created successfully'
# Reset the site using the snapshot.
reset:
service: appserver
cmd:
- cd /app/www/files/config_* && tar -xzf /app/config.tar.gz
- gunzip /app/backdrop.sql.gz
- mysql -u root -h database -P 3306 backdrop < /app/backdrop.sql
- gzip -f /app/backdrop.sql
- echo 'Site reset successfully'
proxy:
# Add a custom sub-domain for phpMyAdmin.
phpmyadmin:
- db.sandbox.lndo.site
@laryn
Copy link
Copy Markdown
Author

laryn commented Jan 2, 2023

The database port number is optional but useful if you will be using the site a lot and want to be able to save a bookmark in a visual database application like BeeKeeper Studio.

@laryn
Copy link
Copy Markdown
Author

laryn commented Jan 2, 2023

Next I'd like to allow to specify the name of the snapshot to save or reset to, with backdrop being the default. This should be fairly painless with https://docs.lando.dev/core/v3/tooling.html#options-driven-tooling

For example, on a contrib module repo that I've set up in Lando for testing, this would make an easy way to save/reset various configurations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment