special sponsors

# SQL Export

Written by: Team Lando Team Lando
Guide Tested: Yes

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

  --host, -h      The database service to use                  [default: "database"]
  --stdout        Dump database to stdout

# Adding the db-export command

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.

  'db-export [file]':
    service: :host
    description: Exports database from a database service to a file
    cmd: /helpers/sql-export.sh
    user: root
        description: The database service to use
        default: database
          - h
        description: Dump database to stdout


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!