{"id":23838354,"url":"https://github.com/gluonfield/dgbr","last_synced_at":"2025-09-07T15:32:45.740Z","repository":{"id":57568422,"uuid":"294961443","full_name":"gluonfield/dgbr","owner":"gluonfield","description":"Dgraph backup restore tool to/from AWS S3 bucket","archived":false,"fork":false,"pushed_at":"2021-02-11T07:31:15.000Z","size":85,"stargazers_count":41,"open_issues_count":0,"forks_count":5,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-01-01T10:38:36.390Z","etag":null,"topics":["backups","database","dgraph","restore","s3"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gluonfield.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-12T14:37:01.000Z","updated_at":"2024-07-08T19:18:08.000Z","dependencies_parsed_at":"2022-08-28T08:20:16.812Z","dependency_job_id":null,"html_url":"https://github.com/gluonfield/dgbr","commit_stats":null,"previous_names":["gluonfield/dgbr"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gluonfield%2Fdgbr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gluonfield%2Fdgbr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gluonfield%2Fdgbr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gluonfield%2Fdgbr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gluonfield","download_url":"https://codeload.github.com/gluonfield/dgbr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232227406,"owners_count":18491727,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backups","database","dgraph","restore","s3"],"created_at":"2025-01-02T16:57:17.797Z","updated_at":"2025-01-02T16:57:18.523Z","avatar_url":"https://github.com/gluonfield.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"![GitHub Logo](/graphics/logo.png)\n# Dgraph Backup Restore (dgbr)\n\n## Details\n`dgbr` is CLI tool allowing to backup/restore Dgraph database to/from AWS S3 bucket. `dgbr` handles backups by requesting Dgraph to export existing database, archiving the data and uploading it to the S3 bucket. Backups can be configured to be made periodically. `dgbr` handles database restore by downlaoding existing archive from S3 bucket, extracting it and importing data/schema to dgraph using live loader. `dgbr` is currently used in production and is planned to be maintained and improved.\n\n## Install\nYou can either download binary release or build `dgbr` from source.\n### From source\n`dgbr` is written in Go, therefore you have to instal the compiler to build it from source.\n```\ngit clone https://github.com/AugustDev/dgbr.git\ngo build\ngo install\n```\n### Release\nIf you choose to download the release, you may add it to your bin path like this.\n```\nwget https://github.com/AugustDev/dgbr/releases/download/1.0.0/dgbr-linux-amd64.gz\ngunzip -c dgbr-linux-amd64.gz \u003e dgbr\nchmod +x dgbr\nsudo mv dgbr /usr/bin/dgbr\n```\n\n## Usage\nBoth Dgraph backup and restore actions require specifying: `AWS_ACCESS_KEY`, `AWS_SECRET_KEY`, `bucket` and `region`.\n### Backup\nIn adition to aforementioned variables `dgbr backup` requires to specify Dgraph `export` path which is specified when starting `dgraph alpha` (Read in Notes). Make sure Dgraph has permission to write to `export` path and that the user calling `dgbr` has permission to access and then delete files from `export` path.\n\n```bash\ndgbr backup \\\n--AWS_ACCESS_KEY=X \\\n--AWS_SECRET_KEY=Y \\\n--bucket=my-dgraph-backups \\\n--region=eu-west-1 \\\n--export=/exports\n```\n### Restore\nRestoring database requires specifying name of the `zip` file in S3 bucket.\n\n```bash\ndgbr restore \\\n--AWS_ACCESS_KEY=X \\\n--AWS_SECRET_KEY=Y \\\n--bucket=dgraph-backups-development \\\n--region=eu-west-1 \\\n--name=dg-my_backup.zip\n```\n\n## Periodic backups\nThere are many ways to schedule tasks. This is one example. To schedule perodic (daily, hourly etc.) backups simply create a script and add it to your cron list. Make sure that `dgbr` is in the appropriate `bin` folder.\n\n```bash\n#!/bin/bash\nexport PATH=\"/usr/local/bin:/usr/bin:/bin\"\n\nAWS_ACCESS_KEY=X\nAWS_SECRET_KEY=Y\nBUCKET=dgraph-backups-development\nREGION=eu-west-1\nEXPORT_PATH=/Users/august/exports\n\ndgbr backup \\\n--AWS_ACCESS_KEY=${AWS_ACCESS_KEY} \\\n--AWS_SECRET_KEY=${AWS_SECRET_KEY} \\\n--bucket=${BUCKET}  \\\n--region=${REGION}  \\\n--export=${EXPORT_PATH} \n```\n\nAn example of hourly export cronjob would be\n```bash\n0 * * * * /Users/august/backup.sh \u003e\u003e /Users/august/log.txt 2\u003e\u00261\n```\nwhere the logs are saved to `/Users/august/log.txt`.\n\n## CLI and flags\n### Backup\nType `dgbr backup --help`\n\n```\nExample use:\n\ndgbr backup --AWS_ACCESS_KEY=X --AWS_SECRET_KEY=Y --bucket=my-dgraph-backups --region=eu-west-1 --export=/exports\n\nUsage:\n  dgbr backup [flags]\n\nFlags:\n      --alphaHost string   alpha server host name (default \"localhost\")\n      --alphaPort string   alpha server port (default \"9080\")\n      --export string      Location where dgraph alpha is exporting data (required) (default \"/exports\")\n      --format string      Export format rdf or json (default \"rdf\")\n  -h, --help               help for backup\n      --host string        Hostname of running instance of Dgraph server (default \"localhost\")\n      --port string        Hostname port (default \"8080\")\n      --prefix string      Prefix appended to backup file name (default \"dg\")\n      --zeroHost string    zero server host name (default \"localhost\")\n      --zeroPort string    zero server port (default \"5080\")\n\nGlobal Flags:\n      --AWS_ACCESS_KEY string   AWS access key for your IAM user (required)\n      --AWS_SECRET_KEY string   AWS secret key for your IAM user (requried)\n      --bucket string           Name of your AWS S3 bucket (requried)\n      --config string           config file (default is $HOME/.dgraph-backup-restore.yaml)\n      --region string           Your AWS S3 bucket region (requried)\n```\n\n### Restore\nType `dgbr restore --help`\n```\nExample use:\n\ndgbr restore --AWS_ACCESS_KEY=X --AWS_SECRET_KEY=Y --bucket=my-dgraph-backups --region=eu-west-1 --name=dg_date.zip\n\nUsage:\n  dgbr restore [flags]\n\nFlags:\n      --alphaHost string   alpha server host name (default \"localhost\")\n      --alphaPort string   alpha server port (default \"9080\")\n  -h, --help               help for restore\n      --name string        backup name for the restore in S3 bucket (required)\n      --zeroHost string    zero server host name (default \"localhost\")\n      --zeroPort string    zero server port (default \"5080\")\n\nGlobal Flags:\n      --AWS_ACCESS_KEY string   AWS access key for your IAM user (required)\n      --AWS_SECRET_KEY string   AWS secret key for your IAM user (requried)\n      --bucket string           Name of your AWS S3 bucket (requried)\n      --config string           config file (default is $HOME/.dgraph-backup-restore.yaml)\n      --region string           Your AWS S3 bucket region (requried)\n```\n\n## Notes\n##### What is my export path?\n\nIf you start `dgraph alpha` using\n```\ndgraph alpha --lru_mb 2048 -p /var/run/dgraph/p -w /var/run/dgraph/w --export /exports\n```\nyour export path is `/exports`.\n\n##### Origin\n\nProject was inspired by `https://github.com/xanthous-tech/dgraph-backup-cli`, yet I found it to have multiple issues and lacking documentation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgluonfield%2Fdgbr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgluonfield%2Fdgbr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgluonfield%2Fdgbr/lists"}