codebak

module
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 2, 2026 License: MIT

README

codebak

Incremental code backup with a beautiful TUI

Release License Go Build Coverage

codebak TUI demo


codebak automatically backs up your code projects with smart change detection. Browse backups, compare versions, and recover files through an interactive terminal UI.

Features

  • Smart Change Detection — Only backs up when git HEAD changes or files are modified
  • Interactive TUI — Navigate projects, versions, and diffs with vim-style keybindings
  • Version Comparison — Diff any two backup versions to see added, modified, and deleted files
  • Line-by-Line Diff — Drill into files to see exactly what changed with colored diffs
  • Integrity Verification — SHA256 checksums ensure your backups are intact
  • Automatic Scheduling — Set-and-forget daily backups via launchd
  • Safe Recovery — Restore with archive or wipe options to protect existing code
Projects view showing backup status for multiple projects

Dashboard with all your projects

Version history with timestamps and git commits

Version history with git commits

Diff result showing added, modified, and deleted files

Compare versions: see what changed

Line-by-line file diff with colored additions and deletions

Drill into files for line-by-line diff

Installation

curl -sSL https://raw.githubusercontent.com/jmcdonald/codebak/main/install.sh | bash

Homebrew

brew install jmcdonald/tap/codebak

From Source

git clone https://github.com/jmcdonald/codebak.git
cd codebak
make install

Quick Start

# 1. Create config file
codebak init

# 2. Edit config (optional)
$EDITOR ~/.codebak/config.yaml

# 3. Run your first backup
codebak run

# 4. Launch the TUI
codebak

Configuration

Config file location: ~/.codebak/config.yaml

source_dir: ~/code           # Directory containing your projects
backup_dir: ~/backups        # Where backups are stored
schedule: daily
time: "03:00"

exclude:                     # Patterns to exclude from backups
  - node_modules
  - .venv
  - __pycache__
  - .git
  - target
  - dist
  - build

retention:
  keep_last: 30              # Keep last N backups per project

Usage

Commands

Command Description
codebak Launch interactive TUI
codebak run [project] Backup changed projects
codebak list <project> List backup versions
codebak verify <project> Verify backup integrity
codebak recover <project> Restore from backup
codebak install Enable daily scheduled backups
codebak status Show config and schedule status

TUI Keybindings

Key Action
j / k Navigate up/down
Enter Select item / drill into file
Backspace Go back
d Enter diff mode
Space Toggle version selection
s Swap diff sides (in file diff view)
v Verify backup
r Recover version
q Quit

Recovery Options

# Restore latest (fails if project exists)
codebak recover myproject

# Restore and archive existing
codebak recover myproject --archive

# Restore and delete existing
codebak recover myproject --wipe

# Restore specific version
codebak recover myproject --version=20241215-100000

How It Works

~/code/                          ~/backups/
├── project-a/                   ├── project-a/
│   └── (your code)      ──►     │   ├── manifest.json
├── project-b/                   │   ├── 20241215-030000.zip
│   └── (your code)              │   └── 20241216-030000.zip
└── project-c/                   └── project-b/
    └── (your code)                  ├── manifest.json
                                     └── 20241216-030000.zip
  1. Detect — Monitors git HEAD or file mtimes for changes
  2. Backup — Creates timestamped zip with exclusions applied
  3. Track — Maintains manifest with checksums and metadata
  4. Prune — Automatically removes old backups per retention policy

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE for details.

Directories

Path Synopsis
cmd
codebak command
internal
adapters/execgit
Package execgit provides a git client adapter using exec.Command.
Package execgit provides a git client adapter using exec.Command.
adapters/maclaunchd
Package maclaunchd provides a launchd service adapter for macOS.
Package maclaunchd provides a launchd service adapter for macOS.
adapters/osfs
Package osfs provides a filesystem adapter using the standard library os package.
Package osfs provides a filesystem adapter using the standard library os package.
adapters/tuisvc
Package tuisvc provides the real implementation of ports.TUIService.
Package tuisvc provides the real implementation of ports.TUIService.
adapters/ziparchiver
Package ziparchiver provides an archiver adapter using the archive/zip package.
Package ziparchiver provides an archiver adapter using the archive/zip package.
cli
Package cli provides the command-line interface with injectable io.Writer for testing.
Package cli provides the command-line interface with injectable io.Writer for testing.
mocks
Package mocks provides mock implementations for testing.
Package mocks provides mock implementations for testing.
ports
Package ports defines interfaces (contracts) for external dependencies.
Package ports defines interfaces (contracts) for external dependencies.
tui

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL