Back to top
Documentation Command-line tool Export command

Export command

The export command exports a SurrealQL script file from a local or remote SurrealDB database server.

Make sure you’ve installed SurrealDB — it should only take a second!

Command options

Argument Description
-c / --conn Optional Sets the url of the database server to connect to

Default is https://cloud.surrealdb.com

-u / --user Required Sets the root, namespace, or database user
-p / --pass Required Sets the password for the specified user
--ns Required Sets the desired namespace from which to export data
--db Required Sets the desired database from which to export data
Positional argument
Argument Description
file Required Sets the desired output file path for the data to written

Example usage

To perform a SurrealQL database export into a local file, in a terminal run the surreal export command with the required arguments.

user@localhost % surreal export --conn http://localhost:8000 --user root --pass root --ns test --db test export.surql
[2022-07-28 15:50:34] INFO  surrealdb::cli The SQL file was exported successfully

Command help

To see the help information and usage instructions, in a terminal run the surreal export --help command without any further arguments. This command gives general information on the arguments, inputs, and additional options for the export command.

user@localhost % surreal help export
Export an existing database as a SurrealQL script

USAGE:
    surreal export [OPTIONS] <file>

ARGS:
    <file>    Path to the sql file to export

OPTIONS:
    -c, --conn <conn>    Remote database server url to connect to [default: https://cloud.surrealdb.com]
        --db <db>        The database to export the data from
    -h, --help           Print help information
        --ns <ns>        The namespace to export the data from
    -p, --pass <pass>    Database authentication password to use when connecting [default: root]
    -u, --user <user>    Database authentication username to use when connecting [default: root]