Skip to main content

A stupidly simple backup tool: single file with zero dependencies

Project description


Shelf Logo

Shelf

A stupidly simple backup tool

Single file • Zero dependencies • Auditable • Reliable

PyPI version Python versions Downloads License

InstallQuick StartFeaturesDocumentation


Shelf is a backup tool that is configurable and extensible. It backs up your dotfiles, config files, scripts, random directories etc to a git repository that you can upload to Github private remote.

One auditable Python file (shelf.py) contains all the logic for backup and restore. It auto-detects OS (macOS/Linux) and uses correct template (macos.toml or linux.toml) for configuration. Each backup session creates detailed structured NDJSON logging for auditability. The following is an example of sources that are enabled for backup:

  • Dotfiles: .zshrc, .gitconfig, .ssh/config, etc.
  • App Configs: VSCode, Vim, tmux, git settings
  • System Prefs: macOS dock, finder, terminal settings (via plist files)
  • Package Managers: Homebrew formulas, casks, taps, and services
  • Custom Fonts: Your installed font collection
  • Recursive Directories: Automatically backup specific subdirectories from multiple projects

Quick Start

# Install
pip install shelf-backup

# Initialize profile
shelf init

# Backup to specific directory
shelf backup ~/my-backups

# Optional: customize what gets backed up
vim ~/.config/shelf/macos.toml

# Restore from backup
shelf restore

Documentation

Advanced Commands
# Backup with git push
shelf backup ~/my-backups --push

# Dry-run restore (preview without making changes)
shelf restore --dry-run

# Restore from specific commit
shelf restore abc1234

# Restore from different location
shelf restore ~/different-backup

# Show backup history
shelf list

# Check system status
shelf status
File Locations
~/.config/shelf/           # Configuration files (TOML)
~/.local/share/shelf/      # Backup data (git repositories)
  └── logs/                # Backup logs (NDJSON)
Requirements
  • Python 3.11+
  • git command (for versioning)
  • brew command (for Homebrew backups on macOS)

No pip packages, no external libraries.

Configuration

Shelf uses a single TOML config file per machine at ~/.config/shelf/{os}.toml. The config is automatically created from templates (macos.toml or linux.toml) shipped with the package, which provide sensible defaults. You can customize it to your needs.

Config Structure

[backup]
path = "~/my-backups"
ignore_patterns = ["*.log", "*.tmp", "node_modules/", "*.so", "*.dylib"]

[git]
enabled = true
auto_commit = true
auto_push = false
commit_message = "Backup: {timestamp}"
branch = "main"

[providers.files]
enabled = true
paths = [
    "~/.zshrc",
    "~/.gitconfig",
    "~/.ssh/config",
    "~/.config/nvim",
    "~/.config/tmux"
]

# Recursive backups from multiple parent directories
# [providers.files.recursive]
# "~/Developer/github" = ["_scripts", ".github", "config"]
# "~/Developer/projects" = ["scripts", "docs"]

[providers.homebrew]
enabled = true
brewfile = true
formulas = true
casks = true
services = true
taps = true

[providers.fonts]
enabled = true
custom_fonts_only = true
system_fonts = false

Configuration Options

Backup Settings:

  • backup.path: Where backups are stored (supports ~ and relative paths)
  • backup.ignore_patterns: Global patterns to exclude from backups

Git Settings:

  • git.enabled: Enable git versioning
  • git.auto_commit: Automatically commit after backup
  • git.auto_push: Automatically push to remote after commit
  • git.commit_message: Commit message template (supports {timestamp}, {date}, {time})
  • git.branch: Git branch to use

Providers:

  • providers.files.paths: Files and directories to backup (auto-detected)
  • providers.files.recursive: Map parent directories to subdirectories to recursively backup
  • providers.homebrew.enabled: Backup Homebrew packages (macOS only)
  • providers.fonts.enabled: List installed custom fonts

Backup Logs and History

Each backup session creates detailed NDJSON structured logs with metadata, timing, and results:

# View backup history
shelf list

# Example output:
# 20250122_143052 - backup - 2025-01-22 14:30:52
# 20250121_091234 - backup - 2025-01-21 09:12:34
# 20250120_160845 - backup - 2025-01-20 16:08:45

Log files contain:

  • Session metadata (timestamp, platform, operation type)
  • File and directory backup results
  • Error details and warnings
  • Git commit information
  • Provider statistics (files copied, sizes, errors)

Log location: {backup_path}/logs/backup_YYYYMMDD_HHMMSS.ndjson

Each log entry is a complete JSON object on its own line, making them easy to parse with tools like jq or analyze programmatically.


Install NowReport Issues

Made for developers who value simplicity

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shelf_backup-0.2.1.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shelf_backup-0.2.1-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file shelf_backup-0.2.1.tar.gz.

File metadata

  • Download URL: shelf_backup-0.2.1.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for shelf_backup-0.2.1.tar.gz
Algorithm Hash digest
SHA256 ec8691de82a2daedce3035ae5bb2381f43039d3c8d4de9662bc9c20a125b59c5
MD5 18ebad0663be42fb7e0bcb8994a5ec35
BLAKE2b-256 ee7ec67800c00d379521b4a643862381b99a0849056718f9db51b845dad06ad9

See more details on using hashes here.

File details

Details for the file shelf_backup-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: shelf_backup-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for shelf_backup-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e4e425b053cac4e7d4c4e4cfdb32dcd429c63d5b49c15730a086bc0a21193ee8
MD5 2a9868e4e40fd395580065f4e812ae08
BLAKE2b-256 3e2c285710eaa162ae237d9c3cb0cce92b9dc62a319222e0a77308190efb3d48

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page