Skip to content

PJC-64/endur

Repository files navigation

Endur

Build

Note

Endur is an actively maintained fork of Tim Kellogg's original dura project. Since the fork, this project is being developed and built with AI assistance (leveraging Antigravity, Google DeepMind's coding assistant). It contains significant modernizations, performance improvements, and feature additions.

Endur is a background process that watches your Git repositories and commits your uncommitted changes without impacting HEAD, the current branch, or the Git index (staged files). If you ever get into an "oh snap!" situation where you think you just lost days of work, use Endur's built-in restore commands to safely and selectively recover your work.

Without endur, you use Ctrl-Z in your editor to get back to a good state. That's so 2021. Computers crash and Ctrl-Z only works on files independently. Endur snapshots changes across the entire repository as-you-go, so you can revert to "4 hours ago" instead of "hit Ctrl-Z like 40 times or whatever". Finally, some sanity.

Key Enhancements & Differences from Original dura

Compared to the upstream dura repository, Endur adds the following features and improvements:

  1. Strict Advisory File Locking: Replaced PID tracking files with OS-level advisory file locks (fs2 crate) for single-instance daemon enforcement.
  2. Unix Domain Sockets (UDS) IPC: Replaced the native TCP loopback setup with a robust, asynchronous Unix Domain Socket communication layer.
  3. Event-Driven & Debounced File Watching: Replaced CPU-heavy active directory polling with native, event-driven file monitoring (notify crate) combined with a 500ms debounce cache.
  4. Git-Aware Filtering: Automatically respects .gitignore rules and ignores the .git/ folder, reducing disk write and commit activity.
  5. Discrete Path Restore: Allows you to restore only specific files or folders from a backup snapshot (e.g. endur restore <hash> --files path/to/file) instead of checking out the entire repository tree.
  6. Built-in CLI Recovery & Interactive TUIs:
    • endur list-snapshots: Lists snapshots since the last formal commit by default; pass --all to see the full history.
    • endur prune: Delete historical backup snapshots based on a target commit, age duration, or retention count to reclaim disk space.
    • endur restore -i: Visual Terminal User Interface (TUI) powered by ratatui (running as a synonym for endur tui) to browse repositories, drill down into snapshots, preview modified files, and selectively restore files using interactive checkboxes (Space to toggle, Enter to restore).
    • endur tui: A comprehensive Control Center TUI to monitor background daemon status, manage watched repositories, inspect live logs, and view performance metrics.
  7. System Startup Service Subcommands: Exposes endur service install and endur service uninstall to register the daemon as a system service automatically (launchd on macOS, systemd on Linux).
  8. Configurable Log Redirection: The endur serve daemon runs completely silently, logging only to a configurable file path (defaults to ~/.cache/endur/endur.log).
  9. Metrics Scraping & Performance Analysis: Exposes an endur metrics subcommand that parses log files to compute backup frequency, snapshot latency, and repository sizes. Supports both raw JSON output and a clean formatted table (-h/--human-readable), enriched with Unicode sparkline trend graphs plotting latency and activity history. Checks stdin to prevent interactive hangs, automatically falling back to cached log paths when run on a TTY.
  10. SQLite Metadata Cache: Snapshot metadata is transparently cached in a SQLite database (~/.cache/endur/snapshot_cache.db). This dramatically speeds up list-snapshots, the TUI, and the GUI on large repositories. The cache is kept warm automatically on every backup and gracefully falls back to a raw Git history walk if the database file is missing or corrupt.
  11. Native Desktop GUI Application (v1.1.0): Structured the project as a Cargo workspace to support a native cross-platform GUI client (crates/endur-desktop) built on Tauri 2.0 and Svelte 5. It packages native desktop installers (macOS DMG, Windows MSI/EXE, Linux DEB/AppImage) and implements a hybrid daemon resolver to integrate seamlessly with the existing CLI/TUI core.

Documentation

  • User Guide: Comprehensive instructions on using and recovering with Endur.
  • Developer Guide: Details on the internal architecture, event-driven loop, UDS socket IPC, and testing.
  • GUI User Guide: Comprehensive guide to installing, configuring, and using the native Desktop GUI application.
  • GUI Developer Guide: Technical details on the Svelte 5 + Tauri desktop client architecture and IPC commands.

How to use

Running the daemon manually in the background (endur serve &) is deprecated (and will be removed in a future release) in favor of running it as an OS-level background service.

1. Install & Start the Startup Service

To register and start the daemon as a startup service:

$ endur service install

This automatically registers the daemon to start on login (using launchd on macOS, systemd on Linux, or Windows Task Scheduler on Windows) and starts the background execution immediately. (If a version of the service is already installed, running this will cleanly stop and remove it first, then register and start the latest version.)

If you ever need to stop and remove the startup service:

$ endur service uninstall

(Note: The raw endur serve and endur kill commands are deprecated, will be removed in a future release, and are intended only for ad-hoc debugging sessions.)

2. Monitor repositories

Let endur know which repositories to watch:

$ endur watch some/git/repo

You can pass a relative or absolute path to the directory you want to watch. If no path is specified, it defaults to the current working directory.

To watch all git repositories under a specific folder (e.g. your development directory), you can run:

$ find ~/Development -type d -name .git -prune | xargs -I{} sh -c "endur watch {}/.."

Make some changes. No need to commit or even stage them. Use any Git tool to see the endur branches:

$ git log --all

endur produces a branch for every real commit you make and makes commits to that branch without impacting your working copy. You keep using Git exactly as you did before.

3. Stop background execution (Direct Mode Only)

To stop a daemon running in direct/debugging mode, run:

$ endur kill

(Note: If the daemon is running as a system service, it will be automatically restarted by the OS. Use endur service uninstall to permanently remove/stop the service.)

How to recover

Endur now provides built-in recovery subcommands:

  1. List snapshots since your last commit (default — most relevant):

    $ endur list-snapshots

    By default this shows only snapshots taken after your most recent formal Git commit (i.e. work-in-progress you haven't committed yet). To see the full historical archive:

    $ endur list-snapshots --all
  2. Restore files from a snapshot:

    • To restore the entire repository state:
      $ endur restore <commit-hash>
    • To restore only specific files or directories (discrete restore):
      $ endur restore <commit-hash> --files path/to/file1.txt path/to/dir/
    • To use the visual interactive mode (supports full or selective checkbox-based restore):
      $ endur restore -i

    These options check out the snapshot files directly to your working directory and staging index, keeping you on your current branch.

  3. Prune historical snapshot branches:

    • To prune snapshots prior to a specific formal commit:
      $ endur prune <commit-hash>
    • To keep snapshots for only the last N formal commits:
      $ endur prune --keep <N>
    • To prune snapshots older than a duration (e.g., 30 days):
      $ endur prune --before 30d
    • To select the cutoff commit interactively:
      $ endur prune -i

    Note: You can pass --gc to immediately run Git Garbage Collection (git gc --prune=now) to reclaim disk space, and --dry-run to preview the deletion.

Tip

Why use endur restore instead of native Git commands? While Endur snapshots are stored as standard Git commits on hidden branches (which you could technically access via git checkout), using Endur's built-in restore process is highly recommended because:

  • Keeps your branch state clean: Native git checkout switches your entire repository to a detached HEAD or another branch, which disrupts your workspace. endur restore extracts snapshot files directly into your active working directory without changing your current branch or branch history.
  • Granular control: You can restore specific files or folders (via --files) instead of the entire tree.
  • Interactive TUI: Using endur restore -i allows you to visually inspect changes and selectively restore only the files you want using checkboxes.

For more details on commands and recovery, see the User Guide.

Install

From crates.io (Recommended)

You can install endur directly via Cargo:

cargo install endur

By Source

  1. Install Rust (e.g., brew install rustup && brew install rust)
  2. Clone this repository:
    git clone https://github.com/PJC-64/endur.git
  3. Navigate to repository base directory (cd endur)
  4. Run:
    cargo install --path .

macOS & Linux (Startup Service)

Endur can be configured as a background service that launches automatically at login (macOS) or boot (Linux) using the built-in subcommand:

$ endur service install

To stop and remove the service, run:

$ endur service uninstall

Windows

  1. Download rustup-init
  2. Clone this repository:
    git clone https://github.com/PJC-64/endur.git
  3. Navigate to repository base directory (cd endur)
  4. Run cargo install --path . Note: If you receive a failure fetching the cargo dependencies try using the local git client for cargo fetches. CARGO_NET_GIT_FETCH_WITH_CLI=true cargo install --path .

Arch Linux

$ paru -S endur-git

Nix / Nixos

Nix is a tool that takes a unique approach to package management and system configuration. NixOS is a Linux distribution built on top of the Nix package manager.

To run endur locally using pre-compiled binaries:

nix shell nixpkgs#endur

If you're willing to contribute and develop, endur also provides its own ready-to-use Nix flake.

To build and run the latest development version of endur locally:

nix run github:PJC-64/endur

To run a development environment with the required tools to develop:

nix develop github:PJC-64/endur

FAQ

Is this stable?

Yes. Lots of people have been using the original dura since 2022 without issue, and this fork has changed no core elements of the backing logic. It uses libgit2 to make the commits, so it's fairly battle hardened.

How often does this check for changes?

Endur uses event-driven file monitoring (notify crate) to listen for filesystem events. It captures changes immediately after they occur, with a 500ms debounce delay to combine rapid consecutive writes into a single snapshot.

This fork brought to you by PJC-64, original 'dura' by Tim Kellogg.

About

No description, website, or topics provided.

Resources

Contributing

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages