Lando ships with a helper
db-export script that is available in all our
LEMP based recipes. Used in the recipe context it should export a database dump
DATABASE.TIMESTAMP.gz into the
You can also export databases from other services.
Postgres export not yet supported
Lando will only handle
mariadb exports at this time.
At the command line execute:
# Export to a file named `DATABASE.TIMESTAMP.gz` lando db-export # Export to a file called dump.sql.gz lando db-export dump.sql.gz # Export from a secondary database lando db-export --host db2 # Dump the result to stdout lando db-export --stdout
Options: --host, -h The database service to use [default: "database"] --stdout Dump database to stdout
If you are not using one of our
php-y recipes you can add the
db-export command and default options to your
.lando.yml as follows.
# The name of the app name: mysql-export # Give me http://mysql-export.lndo.site and https://mysql-export.lndo.site proxy: nginx: - mysql-export.lndo.site # Set up my services services: # Set up a basic webserver running the latest nginx with ssl turned on appserver: via: nginx type: php:7.1 ssl: true webroot: www # Spin up a mariadb container called "database" # NOTE: "database" is arbitrary, you could just as well call this "db" or "kanye" database: # Use the latest version of mysql type: mysql # Optionally forward out our port so we can access it at `localhost:someport`. # This port will change every time you restart this app # # You can also set this to a static port you want to use `portforward:3311`. # You will need to make sure the port is open and avialable portforward: 5309 # Optionally change the default db credentials creds: user: mysql password: mysql database: data1 # Optionally load in all the mysql config files in the config directory # This is relative to the app root # config: # confd: config # Spin up a secondary database just to test things out database2: type: mysql tooling: db-export: service: :host description: Export a database from a database service cmd: /helpers/mysql-export.sh options: host: description: The database service to use default: database alias: - h stdout: description: Dump database to stdout mysql: service: :host description: Drop into a mysql shell on a database service cmd: mysql -u root options: host: description: The database service to use default: database alias: - h 'db-import ': service: :host description: Import into database cmd: /helpers/mysql-import.sh options: host: description: The database service to use default: database alias: - h no-wipe: description: Do not destroy the existing database before an import
You will need to rebuild your app with
lando rebuild to apply the changes to this file. You can check out the full code for this example over here.