Metadata-Version: 2.5
Name: nbkp
Version: 1.9.1
Summary: Nomad Backup: An rsync-based backup tool for nomadic setups where sources and destinations aren't always available — laptops on the move, removable drives, home servers behind changing networks. Sentinel files ensure backups only run when volumes are genuinely present, with optional btrfs or hard-link snapshots for point-in-time recovery.
Author-email: Sami Dalouche <sami.dalouche@gmail.com>
License-Expression: Apache-2.0
License-File: LICENSE
Requires-Python: <3.16,>=3.15
Requires-Dist: fabric<4.0,>=3.0
Requires-Dist: jinja2<4.0,>=3.0
Requires-Dist: mermaid-ascii-diagrams<0.2,>=0.1.1
Requires-Dist: paramiko<6.0,>=5.0
Requires-Dist: platformdirs<5.0,>=4.11.0
Requires-Dist: pydantic-core<3.0,>=2.50
Requires-Dist: pydantic<3.0.0,>=2.14.1
Requires-Dist: pyyaml<7.0,>=6.0
Requires-Dist: rich<16.0,>=15.0
Requires-Dist: typer<1.0.0,>=0.27.0
Provides-Extra: docker
Requires-Dist: cryptography<51.0,>=50.0; extra == 'docker'
Requires-Dist: docker<8.0,>=7.2.0; extra == 'docker'
Provides-Extra: keyring
Requires-Dist: keyring<26.0,>=25.0; extra == 'keyring'
Description-Content-Type: text/markdown

# Nomad Backup (nbkp)

![Stable Version](https://img.shields.io/pypi/v/nbkp?label=stable)
![Pre-release Version](https://img.shields.io/github/v/release/iglootools/nbkp?label=pre-release&include_prereleases&sort=semver)
![Python Versions](https://img.shields.io/pypi/pyversions/nbkp)
![Download Stats](https://img.shields.io/pypi/dm/nbkp)
![GitHub Stars](https://img.shields.io/github/stars/iglootools/nbkp)
![License](https://img.shields.io/github/license/iglootools/nbkp)
![CI Status](https://github.com/iglootools/nbkp/actions/workflows/preflight.yml/badge.svg?branch=main)

A Linux-and-macOS-compatible rsync-based backup tool for nomadic setups where
sources and destinations aren't always available — laptops on the move,
removable drives, home servers behind changing networks.

Sentinel files ensure backups only run when volumes are genuinely present, with
optional btrfs or hard-link snapshots for point-in-time recovery.

Files are backed up as-is in plain directories: no obscure storage formats and
restoring is just a copy.

[![asciicast](https://asciinema.org/a/849UKcGs6WqqAe6i.svg)](https://asciinema.org/a/849UKcGs6WqqAe6i)

<!-- toc -->
**On this page**

- [Installation](#installation)
- [Usage](#usage)
- [Tutorial](#tutorial)
- [Main Use Cases](#main-use-cases)
- [Non-Goals](#non-goals)
- [Known Limitations](#known-limitations)
- [Philosophy](#philosophy)
  - [Design Principles](#design-principles)
  - [Implementation Principles](#implementation-principles)
  - [Nomad backup metaphor](#nomad-backup-metaphor)
- [Contribute](#contribute)
- [Resources](#resources)
- [Related Projects](#related-projects)
  - [Dependencies](#dependencies)
  - [Similar Tools](#similar-tools)
  - [Community](#community)
- [License](#license)
<!-- tocstop -->

## Installation

See
[docs/installation.md](https://github.com/iglootools/nbkp/blob/main/docs/installation.md).

## Usage

See [docs/usage.md](https://github.com/iglootools/nbkp/blob/main/docs/usage.md).

Reference:
[every command and option](https://github.com/iglootools/nbkp/blob/main/docs/cli-reference.md),
[every configuration key](https://github.com/iglootools/nbkp/blob/main/docs/config-reference.md),
and
[the concepts behind them](https://github.com/iglootools/nbkp/blob/main/docs/domain.md).

## Tutorial

For a complete end-to-end walkthrough — backing up a laptop to a Raspberry Pi
*backup hub* with LUKS-encrypted btrfs drives, a *relay* drive that fans data
out to the rest of them, snapshots, automatic mount management, and
keyring-stored passphrases — see
[docs/tutorial.md](https://github.com/iglootools/nbkp/blob/main/docs/tutorial.md).

## Main Use Cases

The tool is primarily designed for the following backup scenarios:

- **Laptop to Server** — back up to your home server whenever you're on the home
  network
- **Laptop to External Drive** — back up to an external drive whenever it's
  connected
- **External Drive to Server** — replicate an external drive to your home server
  when both are available
- **Server to External Drive** — back up your home server to an external drive
- **Easy Setup** - pilot the backups from your laptop, minimal setup on the
  server (`rsync`, `btrfs`)

It replaces the rsync shell scripts you'd normally maintain, adding:

- **Volume detection** (through sentinel files) — only runs when sources and
  destinations are actually available
- **Btrfs and hard-link snapshots** — keeps point-in-time copies so a bad sync
  can't wipe good backups
- **Declarative config** — one YAML file describes all your backup pairs
- **Structured output** — human-readable for convenience and JSON output for
  scripting and automation
- **Automatic LUKS and volume activation (Linux)** — automatically unlock and
  mount volumes before syncs, and unmount and lock them afterward, using
  credentials from the system keyring on your laptop. Encryption itself is left
  to LUKS (or any other at-rest scheme you set up): nbkp only automates the
  unlock/lock routine — see
  [Encryption](https://github.com/iglootools/nbkp/blob/main/docs/domain.md#encryption).

Full feature list:
[docs/features.md](https://github.com/iglootools/nbkp/blob/main/docs/features.md).

Also check
[Why I wrote Nomad Backup (nbkp) to replace my rsync shell scripts](https://www.reddit.com/r/Backup/comments/1rrf97n/i_wrote_nomad_backup_nbkp_to_replace_my_rsync/)
for additional context.

## Non-Goals

nbkp is designed around a single orchestrator (typically a laptop) that
initiates all syncs. It intentionally does not support multi-server topologies
where data flows directly between remote servers, for several reasons:

- **SSH credentials are local.** Keys, proxy-jump chains, and connection options
  in the config describe how the orchestrator reaches each server — not how
  servers reach each other. Forwarding credentials between servers adds security
  risk and configuration complexity.
- **Checks and transfers take different paths.** Pre-flight checks (sentinel
  files, rsync availability, btrfs detection) run from the orchestrator to each
  server independently, but a server-to-server transfer would bypass the
  orchestrator entirely — meaning checks can pass while the actual sync fails.
- **Post-sync operations (snapshots, pruning) assume orchestrator access.**
  Btrfs and hard-link snapshot management connects from the orchestrator to the
  destination, not from the source server.

If you need server-to-server replication:

- **Install nbkp on one of the servers** and configure separate syncs from
  there, treating that server as the orchestrator.
- **Compile a standalone script** with `nbkp sh` and deploy it to the server —
  no Python or nbkp installation required on the target server.
- **Use tools designed for multi-server topologies**: check the
  [Similar Tools](#similar-tools) section for options that support enterpris-y /
  multi-host setups.

## Known Limitations

- No Windows support -- Haven't used it for decades, so no idea wether Cygwin is
  still a thing, if WSL could work, or if there is a completely different
  rsync-like ecosystem that's the preferred way of performing backups.
- No cloud backends -- local and SSH only. Might explore
  [rclone](https://rclone.org/) integration down the road.
- No bidirectional sync -- one-way rsync, on purpose. It could be interesting to
  explore [unison](https://www.cis.upenn.edu/~bcpierce/unison/) integration for
  bidirectional syncs, but I don't have a use case for it for now.
- Not designed for always-on server-to-server replication (though you can deploy
  a generated shell script on a server for that).

## Philosophy

### Design Principles

- Laptop-centric workflows
- Changing networks
- Drives being plugged/unplugged
- Backups happening when possible
- Not always-on infrastructure
- Personal homelab / Raspberry Pi setups

### Implementation Principles

No custom storage format, protocol, or encryption — just proven tools composed
together:

- **rsync + SSH** — handles the actual file transfer, locally or remotely
- **Plain directories** — no obscure storage formats; files are stored as-is and
  restoring is just a copy
- **Btrfs snapshots (optional)** — space-efficient point-in-time copies via
  copy-on-write, with automatic pruning. Each snapshot is a read-only subvolume
  exposing a plain directory tree
- **Hard-link snapshots (optional)** — alternative to btrfs snapshots, works on
  any filesystem that supports hard links, but less efficient and more fragile
- **LUKS (optional)** — full-volume encryption at rest for backup destinations,
  created once with `cryptsetup`; nbkp unlocks and locks it through udisks2.
  Data in transit is protected by SSH

### Nomad backup metaphor

A nomad:

- Moves between places
- Sets up temporary camp
- Carries essential belongings
- Adapts to environment
- Relies on what is present

Which maps to:

- Laptop
- External drive
- Home server
- Network availability
- Mount detection

## Contribute

See
[CONTRIBUTING.md](https://github.com/iglootools/nbkp/blob/main/CONTRIBUTING.md)
for development setup, guidelines, and the documentation of the code.

## Resources

- [Releases](https://pypi.org/project/nbkp/#history)
- [Issue Tracker](https://github.com/iglootools/nbkp/issues)

## Related Projects

### Dependencies

- [rsync](https://rsync.samba.org/) — the underlying file synchronization tool
- [btrfs](https://btrfs.wiki.kernel.org/index.php/Main_Page) — for
  space-efficient point-in-time copies via copy-on-write
- [cryptsetup](https://gitlab.com/cryptsetup/cryptsetup) — to create LUKS
  volumes for full-volume encryption
- [udisks2](https://www.freedesktop.org/wiki/Software/udisks/) — to unlock,
  mount, unmount and lock drives on Linux hosts
- [typer](https://typer.tiangolo.com/) — for building the CLI interface
- [pydantic](https://pydantic.dev/) — for data modeling and validation

### Similar Tools

There are a number of open source backup tools that use rsync, btrfs, or similar
principles. This section describes how `nbkp` compares to some of the popular
ones. One difference applies to every tool below that encrypts its backups: they
encrypt on the client, so the storage never sees cleartext. nbkp keeps plain
directories and relies on disk encryption, so the host holding the drive must be
trusted (see
[Encryption](https://github.com/iglootools/nbkp/blob/main/docs/domain.md#encryption)).
If you believe that the representation is inaccurate or if there are other tools
that should be included in this list, please submit an issue or PR to update
this section.

#### Rsync-related

- **[rsnapshot](https://github.com/rsnapshot/rsnapshot)** — periodic snapshots
  via rsync + hard links (hourly/daily/weekly/monthly). Designed for server/cron
  use with no awareness of removable or intermittent targets. Files stored as
  plain directories.
- **[Back In Time](https://github.com/bit-team/backintime)** — GUI/CLI tool
  using rsync + hard links with scheduling and encfs encryption. Provides a Qt
  interface; uses hard links instead of btrfs snapshots; no sentinel-file
  mechanism for removable drives.
- **[rsync-time-backup](https://github.com/laurent22/rsync-time-backup)** — Time
  Machine-style shell script using rsync `--link-dest`. Single script, no config
  file; uses hard links instead of btrfs snapshots; no volume detection.
- **[rdiff-backup](https://rdiff-backup.net/)** — keeps the latest backup as a
  plain mirror, stores reverse diffs for older versions. Older versions require
  the tool to reconstruct; no removable-drive awareness.
- **[Dirvish](https://web.archive.org/web/20260808042653/https://dirvish.org/)**
  — rotating network backup system using rsync + hard links. Oriented toward
  server-pull workflows; no removable-drive detection or btrfs support.
- **[VaultSync](https://github.com/ATAC-Helicopter/VaultSync)** — cross-platform
  desktop and CLI backup tool using rsync (macOS/Linux) and robocopy (Windows).
  Provides a GUI, scheduled backups, snapshot history, encryption, and retention
  policies. Stores backups as plain directories; no btrfs integration or
  sentinel-file mechanism.
- **[BmuS](https://github.com/back-me-up-scotty/bmus)** — bash-based backup tool
  using rsync + hard-link snapshots with GFS retention, gocryptfs/GPG
  encryption, MySQL/MariaDB dumps, and rclone cloud uploads. Stores backups as
  plain directories; generates an HTML dashboard; no btrfs integration or
  sentinel-file mechanism.
- **[Duplicity](https://duplicity.us/)** — GPG-encrypted tar volumes with
  librsync incremental transfers. Not browsable as plain directories;
  full+incremental chain model; no btrfs integration.

#### Deduplicating

- **[BorgBackup](https://www.borgbackup.org/)** — chunk-level deduplication with
  compression and authenticated encryption. Proprietary repository format (not
  plain directories); requires `borg` on the remote side; no removable-drive
  detection.
- **[borgmatic](https://torsion.org/borgmatic/)** — configuration-driven wrapper
  around BorgBackup that adds YAML config, scheduling, database dumps
  (PostgreSQL, MySQL, SQLite, etc.), monitoring integrations, and credential
  management. Same proprietary Borg format underneath; no rsync or
  removable-drive support.
- **[Restic](https://restic.net/)** — content-addressable backups with
  encryption by default, supporting many backends (local, S3, SFTP, B2).
  Proprietary format; restoring requires the restic tool; no volume detection.
- **[Backrest](https://github.com/garethgeorge/backrest)** — web-based backup
  orchestrator built on restic, distributed as a single Go binary. Provides a
  web UI for cron-scheduled backups, snapshot browsing, and file restoration
  across all restic backends (local, SFTP, S3, B2, rclone). Proprietary restic
  format; no rsync, btrfs, or removable-drive support.
- **[Kopia](https://kopia.io/)** — content-addressable storage with encryption,
  compression, and both CLI/GUI. Proprietary format; includes an optional
  scheduling server; no removable-drive or btrfs support.
- **[Vykar](https://vykar.borgbase.com/)** — fast, encrypted, deduplicated
  backup tool written in Rust with content-defined chunking. Supports local, S3,
  SFTP, and a dedicated REST server; includes a desktop GUI and built-in WebDAV
  for browsing snapshots. Proprietary repository format; no rsync, btrfs, or
  removable-drive support.

#### Btrfs / snapshot-focused

- **[btrbk](https://github.com/digint/btrbk)** — btrfs-native snapshot
  management with send/receive for remote transfers. Btrfs-only (no rsync); more
  sophisticated retention policies (hourly/daily/weekly/monthly); no non-btrfs
  filesystem support.
- **[Snapper](http://snapper.io/)** — automated btrfs snapshot creation with
  timeline-based retention and rollback. Local snapshot management only; no
  rsync or remote transfer; no external backup targets.
- **[Timeshift](https://github.com/linuxmint/timeshift)** — system restore via
  rsync + hard links or btrfs snapshots. Targets root filesystem for
  system-level rollback; excludes user data by default; no remote backup.

#### Continuous / real-time

- **[Syncthing](https://syncthing.net/)** — continuous peer-to-peer file
  synchronization across devices. Decentralized (no central server); syncs
  bidirectionally in real time; no snapshots or point-in-time recovery; designed
  for keeping folders in sync rather than creating backups.
- **[Lsyncd](https://lsyncd.github.io/lsyncd/)** — monitors directories via
  inotify and triggers rsync (or other tools) on changes. Daemon-based,
  continuous replication; designed for server-to-server mirroring; no snapshot
  management or removable-drive awareness.

#### Cloud / multi-backend

- **[Rclone](https://rclone.org/)** — syncs files to and between 70+ cloud and
  remote backends (S3, SFTP, Google Drive, etc.). Can transfer server-to-server
  directly; not rsync-based; no btrfs integration or volume detection.

#### Bidirectional sync

- **[Unison](https://github.com/bcpierce00/unison)** — bidirectional file
  synchronization between two hosts. Detects conflicts; requires Unison on both
  sides with matching versions; no snapshots or removable-drive awareness.

#### Enterprise / multi-host

- **[Bacula](https://www.bacula.org/) / [Bareos](https://www.bareos.com/)** —
  enterprise client-server backup with a director, storage daemons, and file
  daemons across multiple hosts. Full multi-server topology; proprietary catalog
  and storage format; significant setup complexity.
- **[Amanda](https://www.amanda.org/)** — network backup orchestrating multiple
  clients from a central server. Designed for tape and disk pools; uses native
  dump/tar; heavier infrastructure than nbkp targets.
- **[UrBackup](https://www.urbackup.org/)** — client-server backup system with a
  web UI for managing image and file backups across multiple machines. Requires
  a dedicated server process; proprietary transfer protocol; no rsync or btrfs
  integration.
- **[Velero](https://velero.io/)** — backup and disaster recovery for Kubernetes
  clusters, snapshotting persistent volumes and cluster resources.
  Kubernetes-specific; not applicable to general-purpose file backups.

### Community

- **[r/Backup](https://www.reddit.com/r/Backup/)** — Reddit community for
  discussing backup strategies, tools, and best practices.

## License

This project is licensed under the
[Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0) - see the
LICENSE file for details.
