|
| 1 | +--- |
| 2 | +title: Backup List Tool |
| 3 | +--- |
| 4 | + |
| 5 | +The `lsbackup` command-line tool prints information about the stored backups in a user-defined location. |
| 6 | + |
| 7 | +## Parameters |
| 8 | + |
| 9 | +The `lsbackup` command has two flags: |
| 10 | + |
| 11 | +```txt |
| 12 | +Flags: |
| 13 | + -h, --help help for lsbackup |
| 14 | + -l, --location string Sets the source location URI (required). |
| 15 | + --verbose Outputs additional info in backup list. |
| 16 | +``` |
| 17 | + |
| 18 | +- `--location`: indicates a [source URI](#source-uri) with Dgraph backup objects. This URI supports all the schemes used for backup. |
| 19 | +- `--verbose`: if enabled will print additional information about the selected backup. |
| 20 | + |
| 21 | +For example, you can execute the `lsbackup` command as follows: |
| 22 | + |
| 23 | +```sh |
| 24 | +dgraph lsbackup -l <source-location-URI> |
| 25 | +``` |
| 26 | + |
| 27 | +### Source URI |
| 28 | + |
| 29 | +Source URI formats: |
| 30 | + |
| 31 | +- `[scheme]://[host]/[path]?[args]` |
| 32 | +- `[scheme]:///[path]?[args]` |
| 33 | +- `/[path]?[args]` (only for local or NFS) |
| 34 | + |
| 35 | +Source URI parts: |
| 36 | + |
| 37 | +- `scheme`: service handler, one of: `s3`, `minio`, `file` |
| 38 | +- `host`: remote address; e.g.: `dgraph.s3.amazonaws.com` |
| 39 | +- `path`: directory, bucket or container at target; e.g.: `/dgraph/backups/` |
| 40 | +- `args`: specific arguments that are ok to appear in logs |
| 41 | + |
| 42 | +## Output |
| 43 | + |
| 44 | +The following snippet is an example output of `lsbackup`: |
| 45 | + |
| 46 | +```json |
| 47 | +[ |
| 48 | + { |
| 49 | + "path": "/home/user/Dgraph/20.11/backup/manifest.json", |
| 50 | + "since": 30005, |
| 51 | + "backup_id": "reverent_vaughan0", |
| 52 | + "backup_num": 1, |
| 53 | + "encrypted": false, |
| 54 | + "type": "full" |
| 55 | + }, |
| 56 | +] |
| 57 | +``` |
| 58 | + |
| 59 | +If the `--verbose` flag was enabled, the output would look like this: |
| 60 | + |
| 61 | +```json |
| 62 | +[ |
| 63 | + { |
| 64 | + "path": "/home/user/Dgraph/20.11/backup/manifest.json", |
| 65 | + "since": 30005, |
| 66 | + "backup_id": "reverent_vaughan0", |
| 67 | + "backup_num": 1, |
| 68 | + "encrypted": false, |
| 69 | + "type": "full", |
| 70 | + "groups": { |
| 71 | + "1": [ |
| 72 | + "dgraph.graphql.schema_created_at", |
| 73 | + "dgraph.graphql.xid", |
| 74 | + "dgraph.drop.op", |
| 75 | + "dgraph.type", |
| 76 | + "dgraph.cors", |
| 77 | + "dgraph.graphql.schema_history", |
| 78 | + "score", |
| 79 | + "dgraph.graphql.p_query", |
| 80 | + "dgraph.graphql.schema", |
| 81 | + "dgraph.graphql.p_sha256hash", |
| 82 | + "series" |
| 83 | + ] |
| 84 | + } |
| 85 | + }, |
| 86 | +] |
| 87 | +``` |
| 88 | + |
| 89 | +### Return values |
| 90 | + |
| 91 | +- `path`: Name of the backup |
| 92 | + |
| 93 | +- `since`: is the timestamp at which this backup was taken. It's called Since because it will become the timestamp from which to backup in the next incremental backup. |
| 94 | + |
| 95 | +- `groups`: is the map of valid groups to predicates at the time the backup was created. This is printed only if `--verbose` flag is enabled |
| 96 | + |
| 97 | +- `encrypted`: Indicates whether this backup is encrypted or not |
| 98 | + |
| 99 | +- `type`: Indicates whether this backup is a full or incremental one |
| 100 | + |
| 101 | +- `drop_operation`: lists the various DROP operations that took place since the last backup. These are used during restore to redo those operations before applying the backup. (This is printed only if `--verbose` flag is enabled) |
| 102 | + |
| 103 | +- `backup_num`: is a monotonically increasing number assigned to each backup in a series. The full backup as BackupNum equal to one and each incremental backup gets assigned the next available number. This can be used to verify the integrity of the data during a restore. |
| 104 | + |
| 105 | +- `backup_id`: is a unique ID assigned to all the backups in the same series. |
| 106 | + |
| 107 | + |
| 108 | +## Examples |
| 109 | + |
| 110 | +### S3 |
| 111 | + |
| 112 | +Checking information about backups stored in an AWS S3 bucket: |
| 113 | + |
| 114 | +```sh |
| 115 | +dgraph lsbackup -l s3:///s3.us-west-2.amazonaws.com/dgraph_backup |
| 116 | +``` |
| 117 | + |
| 118 | +You might need to set up access and secret key environment variables in the shell (or session) you are going to run the `lsbackup` command. For example: |
| 119 | +``` |
| 120 | +AWS_SECRET_ACCESS_KEY=<paste-your-secret-access-key> |
| 121 | +AWS_ACCESS_ID=<paste-your-key-id> |
| 122 | +``` |
| 123 | + |
| 124 | +### MinIO |
| 125 | + |
| 126 | +Checking information about backups stored in a MinIO bucket: |
| 127 | + |
| 128 | +```sh |
| 129 | +dgraph lsbackup -l minio://localhost:9000/dgraph_backup |
| 130 | +``` |
| 131 | + |
| 132 | +In case the MinIO server is started without `tls`, you must specify that `secure=false` as it set to `true` by default. You also need to set the environment variables for the access key and secret key. |
| 133 | + |
| 134 | +In order to get the `lsbackup` running, you should following these steps: |
| 135 | + |
| 136 | +- Set `MINIO_ACCESS_KEY` as an environment variable for the running shell this can be done with the following command: |
| 137 | + (`minioadmin` is the default access key, unless is changed by the user) |
| 138 | + |
| 139 | + ``` |
| 140 | + export MINIO_ACCESS_KEY=minioadmin |
| 141 | + ``` |
| 142 | + |
| 143 | +- Set MINIO_SECRET_KEY as an environment variable for the running shell this can be done with the following command: |
| 144 | + (`minioadmin` is the default secret key, unless is changed by the user) |
| 145 | + |
| 146 | + ``` |
| 147 | + export MINIO_SECRET_KEY=minioadmin |
| 148 | + ``` |
| 149 | + |
| 150 | +- Add the argument `secure=false` to the `lsbackup command`, that means the command will look like: (the double quotes `"` are required) |
| 151 | + |
| 152 | + ```sh |
| 153 | + dgraph lsbackup -l "minio://localhost:9000/<bucket-name>?secure=false" |
| 154 | + ``` |
| 155 | + |
| 156 | +### Local |
| 157 | + |
| 158 | +Checking information about backups stored locally (on disk): |
| 159 | + |
| 160 | +```sh |
| 161 | +dgraph lsbackup -l ~/dgraph_backup |
| 162 | +``` |
0 commit comments