Importing and Exporting data from Dgraph Cloud
We’re overhauling Dgraph’s docs to make them clearer and more approachable. If you notice any issues during this transition or have suggestions, please let us know.
Importing data into Dgraph Cloud
-
Obtain dgraph binary or the latest docker image by following the installation instructions. This is required to run Dgraph CLI command
dgraph live
. -
Obtain the
gRPC endpoint
of your Dgraph Cloud backend and a validClient API key
.An administrator gets those information with the following steps:
-
Log into the Dgraph Cloud account, select the backend
-
In the
Admin
section of the Dgraph Cloud console, go toSettings
and copy the value of thegRPC Endpoint
from theGeneral
tab. -
Access the
API Keys
tab to generate anClient API Key
.The gRPC endpoint is different from the
GraphQL endpoint
. The gRPC endpoint looks like<domain>:443
-
-
Run the Live Loader as follows:
Load multiple data files by using
When the path provided with -f, --files
option is a directory, then all files
ending in .rdf, .rdf.gz, .json, and .json.gz will be loaded. Be sure that your
schema file has another extension (.txt or .schema for example).
Exporting data from Dgraph Cloud
You can export your data as an Administrator from one Dgraph Cloud backend, and then import this data back into another Dgraph instance or Dgraph Cloud backend. You can also export data from Dgraph Cloud using the Dgraph Cloud API. For more information, see Cloud API documentation.
To import data to Dgraph Cloud, see Live Loader.
As an Administrator
you can export data from a Dgraph Cloud shared instance or
dedicated instance. On a dedicated instance with multi-tenancy feature enabled
you can export data across the cluster, or a specific namespace depending on the
type of administrative privileges you have.
Exporting data from Dgraph Cloud using the console
- In the
Admin
section of the Dgraph Cloud console, go toSettings
. - In the
Exports
tab, clickCreate Export
. - In the
New export
dialog, select the format you want to export. - Click
Create
.
Depending on the format that you chose to create an export, three files are generated.
Ensure that you download these files as soon as possible because the links to download these files expire after 48 hours from the time they were generated.
Exporting data from Dgraph Cloud using a GraphQL client
-
Generate API Key for authentication.
-
Make a note of the GraphQL endpoint for the instance from
Overview
in the Dgraph Cloud console. Replace/graphql
with/admin/slash
in the GraphQL endpoint to get the<ADMIN_ENDPOINT>
. -
Authenticate the
admin
API requests by adding the<APIKEY>
as theDg-Auth
header to every HTTP request. -
To export data you need to send authenticated request to
<ADMIN_ENDPOINT>
. -
Export data in JSON or RDF
<FORMAT>
using this mutation:A response similar to this appears:
-
Make a note of the
<EXPORT_ID>
and the<TASK_ID>
. -
To get the status of export and the signed URLs to download the exported files, use this mutation:
Depending on the format that you chose to create an export, three files are generated.
curl -O <SIGNED_URL>
to download the
files to the current directory. Exporting data from Dgraph Cloud programmatically
You can also export data from Dgraph Cloud programmatically using the Dgraph Cloud API. For more information, see Cloud API documentation.
Exporting data with multi-tenancy feature enabled in Dgraph Cloud
With Multi-Tenancy feature enabled, for any GraphQL request you need to
provide the accessJWT
for the specific user in the X-Dgraph-AccessToken
header.
You can trigger two types of exports:
- Cluster-wide export: this is an export of the entire backend (including all namespaces). This request can be only triggered by the Guardian of Galaxy users.
- Namespace-specific export: this is an export of a specific namespace. This request can be triggered by the Guardian of Galaxy users and by the Guardian of Namespace users.
Cluster-wide exports
This can only be done by the Guardian of Galaxy users (super admin), the steps are:
-
Get the
accessJWT
token for the Guardian of Galaxy user. Send the following GraphQL mutation to the/admin
endpoint:Your variables should be referring to the Guardian of Galaxy user:
-
Once obtained the
accessJWT
token you need to pass it inX-Dgraph-AccessToken
Header and only then you can send the following GraphQL mutation to/admin/slash
endpoint: -
Once done, you can now send the following GraqhQL mutation to get the
signedUrls
from where you can download your export files:
Namespace-specific exports
Namespace-specific exports can be triggered by the Guardian of Galaxy users.
In this case you can follow the same steps for the Cluster-wide exports and
replace the namespace value from -1
to the namespace you want to export. It is
important that you get the accessJWT
token for the Guardian of Galaxy user
and pass it in the X-Dgraph-AccessToken
header.
For example, if you want to export the namespace 0x123
your GraphQL request
sent to the /admin/slash
endpoint would look like:
You can also trigger namespace-specific export using the Guardian of Namespace
users, in this case there is no need to specify any namespace in the GraphQL
request as these users can only export their own namespace. It is important that
you get the accessJWT
token for the Guardian of Namespace user and pass it
in the X-Dgraph-AccessToken
header.
The GraphQL request sent to the /admin/slash
endpoint would be:
Was this page helpful?