Importing and Exporting data from Dgraph Cloud
Exporting and Importing Data in 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. For more information about how to export data in Dgraph Cloud, see Export data. You can also export data from Dgraph Cloud programatically using the Dgraph Cloud API. For more information, see Cloud API documentation.
To import data to Dgraph Cloud, see live loader.
Exporting Data with Multi-Tenancy feature enabled in Dgraph Cloud
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 (AKA Super Admin), the steps are:
- Get the
accessJWT
token for the Guardian of Galaxy user. Send the following GraphQL mutation to the/admin
endpoint:
mutation login($userId: String, $password: String, $namespace: Int) {
login(userId: $userId, password: $password, namespace: $namespace) {
response {
accessJWT
refreshJWT
}
}
}
Your variables should be referring to the Guardian of Galaxy user:
{
"userId": "groot",
"password": "password",
"namespace": 0
}
- 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:
mutation {
export (namespace: -1) {
response { code message }
exportId
taskId
}
}
- Once done, you can now send the following GraqhQL mutation to get the
signedUrls
from where you can download your export files:
query {
exportStatus (
exportId:"<paste-your-exportId>"
taskId: "<paste-your-taskId>"
){
kind
lastUpdated
signedUrls
status
}
}
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’s important that you get the accessJWT
token for the Guardian of Galaxy user and pass it in the X-Dgraph-AccessToken
header.
E.g. if you want to export the namespace 0x123
your GraphQL request sent to the /admin/slash
endpoint would look like:
mutation {
export (namespace: 123) {
response { code message }
exportId
taskId
}
}
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’s 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:
mutation {
export {
response { code message }
exportId
taskId
}
}