special sponsors
SQL Export
Lando ships with a helper db-export
script that is available in all our LAMP
and LEMP
based recipes. Used in the recipe context it should export a database dump DATABASE.TIMESTAMP.gz
into the /app
directory.
You can also export databases from other services.
Usage
At the command line execute:
lando db-export
Examples
# Export to a file named `DATABASE.TIMESTAMP.gz`
lando db-export
# Export to a file called dump.sql.gz
lando db-export dump.sql
# Export from a secondary database
lando db-export --host db2
# Dump the result to stdout
lando db-export --stdout
# Dump to an absolute path
# NOTE: this is an absolute path in the target container, not on you host
lando db-export /db/dump.zip
Options
Options:
--host, -h The database service to use [default: "database"]
--stdout Dump database to stdout
db-export
command
Adding the If you are not using one of our LAMPy recipes you can add the db-export
command and default options to the 'tooling' section of your Landofile.
tooling:
'db-export [file]':
service: :host
description: Exports database from a database service to a file
cmd: /helpers/sql-export.sh
user: root
options:
host:
description: The database service to use
default: database
alias:
- h
stdout:
description: Dump database to stdout
FULL CODE EXAMPLE!
If you are interested in checking out the fully-armed and operational source code for this guide then check out this repo here.
Have a Lando question you'd like to see as a guide? Suggest one!
Want to write a Lando guide? Learn how!