Skip to content

Conversation

@swaploard
Copy link

@swaploard swaploard commented Nov 19, 2025

Description

Feature]: Backing up database file via the CLI #704

Related Issues

#704

Closes #

Checklist when merging to main

  • No compiler warnings (if applicable)
  • Code is formatted with rustfmt
  • No useless or dead code (if applicable)
  • Code is easy to understand
  • Doc comments are used for all functions, enums, structs, and fields (where appropriate)
  • All tests pass
  • Performance has not regressed (assuming change was not to fix a bug)
  • 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 . 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 Summary

  • 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

Important Files Changed

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

Sequence Diagram

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"
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile
React with 👍 or 👎 to share your feedback on this new summary format

@xav-db
Copy link
Member

xav-db commented Nov 23, 2025

@swaploard please fix failing clippy checks

@swaploard
Copy link
Author

Sure

@swaploard
Copy link
Author

There was one formatting error for the string that I fixed, but some errors were coming from the Git workflows, so I pulled from the main branch in hope of fixing those errors. I think @xav-db can help me here.

@xav-db
Copy link
Member

xav-db commented Nov 24, 2025

should be okay now I think

@xav-db xav-db self-requested a review November 24, 2025 00:42
@xav-db
Copy link
Member

xav-db commented Nov 26, 2025

@swaploard please fix clippy checks

@xav-db
Copy link
Member

xav-db commented Nov 26, 2025

should be simple unused import fix

@xav-db xav-db self-requested a review November 29, 2025 18:00
Copy link
Member

@xav-db xav-db left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now

@xav-db xav-db merged commit 9760c6c into HelixDB:dev Dec 8, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants