Commit 9760c6c
authored
## Description
Feature]: Backing up database file via the CLI #704
## Related Issues
#704
Closes #
## Checklist when merging to main
<!-- Mark items with "x" when completed -->
- [x] No compiler warnings (if applicable)
- [x] Code is formatted with `rustfmt`
- [x] No useless or dead code (if applicable)
- [x] Code is easy to understand
- [x] Doc comments are used for all functions, enums, structs, and
fields (where appropriate)
- [x] All tests pass
- [x] Performance has not regressed (assuming change was not to fix a
bug)
- [x] Version number has been updated in `helix-cli/Cargo.toml` and
`helixdb/Cargo.toml`
## Additional Notes
Implemented a backup CLI to back up the selected instance using the
command: cargo run --bin helix backup dev --output <output-path>. This
addresses the issue mentioned in the feature request: "Backing up
database file via the CLI" (#704).
If a path is not provided, the CLI will create a directory in the
current path with a timestamp. If the file size exceeds 10GB, the CLI
will prompt for confirmation before proceeding. Additionally, if
read/write permissions are unavailable, it will print a permission error
message.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
- Implements `helix backup` CLI command to copy instance database files
(`data.mdb` and `lock.mdb`) to a backup directory with optional custom
output path
- Adds size warnings for backups over 10GB and permission checks before
copying files
<details><summary><h3>Important Files Changed</h3></summary>
| Filename | Overview |
|----------|----------|
| helix-cli/src/commands/backup.rs | New backup command implementation
with permission checks and size warnings; missing lock_file existence
check before metadata call |
</details>
</details>
<details><summary><h3>Sequence Diagram</h3></summary>
```mermaid
sequenceDiagram
participant User
participant CLI as "helix backup"
participant ProjectContext
participant FileSystem
User->>CLI: "helix backup <instance> --output <path>"
CLI->>ProjectContext: "find_and_load()"
ProjectContext-->>CLI: "project context"
CLI->>ProjectContext: "get_instance(instance_name)"
ProjectContext-->>CLI: "instance config"
CLI->>FileSystem: "check data_file.exists()"
FileSystem-->>CLI: "exists"
CLI->>FileSystem: "metadata(data_file)"
FileSystem-->>CLI: "file size"
CLI->>FileSystem: "metadata(lock_file)"
FileSystem-->>CLI: "file size"
alt size > 10GB
CLI->>User: "Warn: size is X GB"
CLI->>User: "Confirm: continue?"
User-->>CLI: "yes/no"
alt user cancels
CLI->>User: "Backup aborted"
end
end
CLI->>FileSystem: "check_read_write_permission(data_file)"
FileSystem-->>CLI: "permissions ok"
CLI->>FileSystem: "check_read_write_permission(lock_file)"
FileSystem-->>CLI: "permissions ok"
CLI->>FileSystem: "copy(data_file)"
FileSystem-->>CLI: "copied"
CLI->>FileSystem: "copy(lock_file)"
FileSystem-->>CLI: "copied"
CLI->>User: "Backup created successfully"
```
</details>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
File tree
5 files changed
+129
-1
lines changed- helix-cli
- src
- commands
5 files changed
+129
-1
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| |||
163 | 165 | | |
164 | 166 | | |
165 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
166 | 178 | | |
167 | 179 | | |
168 | 180 | | |
| |||
212 | 224 | | |
213 | 225 | | |
214 | 226 | | |
215 | | - | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
216 | 231 | | |
217 | 232 | | |
218 | 233 | | |
| |||
0 commit comments