Commit 76c508a
feat (backup): improve lsbackup tool (#9693)
Fixes #9684
## Improve `lsbackup` Tool
### User-Facing Changes
#### CLI: `dgraph lsbackup`
| Flag | Type | Description |
|---|---|---|
| `--since-date` | `string` | Only show backups on or after this date
(YYYY-MM-DD or RFC3339) |
| `--until-date` | `string` | Only show backups on or before this date
(YYYY-MM-DD or RFC3339) |
| `--last-n-days` | `int` | Only show backups from the last N calendar
days (mutually exclusive with `--since-date`) |
| `--summary` | `bool` | Print summary statistics (total count, series
count, oldest/newest, last full/incremental) to stderr |
| `--verbose` | `bool` | **Behavior changed** — now reads the full
`manifest.json` to include predicate groups and drop operations. Without
it, the lighter `manifest_summary.json` is used. |
**Example usage:**
```bash
# List backups from the last 7 days with summary stats
dgraph lsbackup --location /data/backups --last-n-days 7 --summary
# List backups in a date range
dgraph lsbackup --location /data/backups --since-date 2026-01-01 --until-date 2026-03-31
# Include full group/predicate detail
dgraph lsbackup --location /data/backups --verbose
```
#### GraphQL: `listBackups` Query
New optional input fields on the `listBackups` admin query:
| Field | Type | Description |
|---|---|---|
| `sinceDate` | `String` | Only return backups on or after this date |
| `untilDate` | `String` | Only return backups on or before this date |
| `lastNDays` | `Int` | Only return backups from the last N days
(mutually exclusive with `sinceDate`) |
| `fullManifest` | `Boolean` | When `true`, reads the full manifest
including predicate groups and drop ops. Default `false`. |
**Example query:**
```graphql
query {
listBackups(input: {
location: "/data/backups"
sinceDate: "2026-01-01"
untilDate: "2026-03-31"
fullManifest: true
}) {
backupId backupNum type path encrypted since
groups { groupId predicates }
}
}
```
#### Backup Output: New `manifest_summary.json`
Every backup now writes a `manifest_summary.json` alongside
`manifest.json`. This is a lightweight version that omits predicate
groups and drop operations, making listing operations faster for large
backup histories. The full `manifest.json` remains unchanged and is
still used for restore.
---
### Internal / Developer Changes
**New types in `worker` package:**
- `ManifestBase` — shared fields between full and summary manifests
- `MasterManifestSummary` — lightweight manifest container (no
groups/drop ops)
- `BackupDateFilter` — date-range filter with `Since` and `Until`
pointers
- `BackupListStats` — summary statistics struct
**New functions in `worker` package:**
- `FilterManifestsByDate()` — filters manifests by a `BackupDateFilter`
- `ComputeBackupListStats()` — computes aggregate stats over a manifest
list
**Signature changes:**
- `ListBackupManifests()` — new `forceFull bool` parameter (3rd arg)
- `ProcessListBackups()` — new `forceFull bool` parameter (4th arg)
---
### Files Changed
| File | Change |
|---|---|
| `worker/backup_manifest.go` | Core types, filtering, stats, summary
read/write |
| `worker/backup.go` | Write `manifest_summary.json` during backup;
updated signatures |
| `worker/backup_handler.go` | Updated `ProcessListBackups` signature |
| `backup/run.go` | New CLI flags, filter/summary logic |
| `graphql/admin/list_backups.go` | GraphQL resolver wired with filter +
`fullManifest` |
| `graphql/admin/endpoints.go` | New GraphQL schema fields |
### New Test Files
| File | Coverage |
|---|---|
| `backup/run_test.go` | Date parsing, filter construction |
| `graphql/admin/list_backups_test.go` | GraphQL date filter, manifest
conversion |
| `worker/backup_manifest_test.go` | `FilterManifestsByDate`,
`ComputeBackupListStats`, summary serialization |
| `systest/backup/filesystem/backup_test.go` | E2E: summary manifest
creation, GraphQL filter matrix, input validation |
| `systest/integration2/backup_summary_compat_test.go` | Backward compat
when `manifest_summary.json` is missing |
---------
Co-authored-by: Shivaji Kharse <[email protected]>1 parent ed78681 commit 76c508a
16 files changed
Lines changed: 2520 additions & 50 deletions
File tree
- backup
- graphql/admin
- systest
- backup
- encryption
- filesystem
- testdata
- minio-large
- minio
- integration2
- worker
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
52 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
53 | 58 | | |
54 | 59 | | |
55 | 60 | | |
| |||
158 | 163 | | |
159 | 164 | | |
160 | 165 | | |
161 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
162 | 175 | | |
163 | 176 | | |
164 | 177 | | |
| |||
247 | 260 | | |
248 | 261 | | |
249 | 262 | | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
250 | 314 | | |
251 | | - | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
252 | 323 | | |
253 | 324 | | |
254 | 325 | | |
| 326 | + | |
255 | 327 | | |
256 | 328 | | |
257 | 329 | | |
| |||
269 | 341 | | |
270 | 342 | | |
271 | 343 | | |
272 | | - | |
273 | 344 | | |
274 | 345 | | |
275 | 346 | | |
| |||
291 | 362 | | |
292 | 363 | | |
293 | 364 | | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
294 | 388 | | |
295 | 389 | | |
296 | 390 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
191 | 212 | | |
192 | 213 | | |
193 | 214 | | |
| |||
0 commit comments