nbkp 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. nbkp-0.1.0/LICENSE +201 -0
  2. nbkp-0.1.0/PKG-INFO +188 -0
  3. nbkp-0.1.0/README.md +167 -0
  4. nbkp-0.1.0/nbkp/__init__.py +3 -0
  5. nbkp-0.1.0/nbkp/cli.py +747 -0
  6. nbkp-0.1.0/nbkp/config/__init__.py +45 -0
  7. nbkp-0.1.0/nbkp/config/loader.py +62 -0
  8. nbkp-0.1.0/nbkp/config/protocol.py +623 -0
  9. nbkp-0.1.0/nbkp/config/resolution.py +55 -0
  10. nbkp-0.1.0/nbkp/democli.py +679 -0
  11. nbkp-0.1.0/nbkp/output.py +927 -0
  12. nbkp-0.1.0/nbkp/preflight.py +694 -0
  13. nbkp-0.1.0/nbkp/remote/__init__.py +15 -0
  14. nbkp-0.1.0/nbkp/remote/fabricssh.py +84 -0
  15. nbkp-0.1.0/nbkp/remote/resolution.py +99 -0
  16. nbkp-0.1.0/nbkp/remote/ssh.py +155 -0
  17. nbkp-0.1.0/nbkp/scriptgen.py +1200 -0
  18. nbkp-0.1.0/nbkp/sync/__init__.py +37 -0
  19. nbkp-0.1.0/nbkp/sync/btrfs.py +227 -0
  20. nbkp-0.1.0/nbkp/sync/hardlinks.py +150 -0
  21. nbkp-0.1.0/nbkp/sync/ordering.py +66 -0
  22. nbkp-0.1.0/nbkp/sync/rsync.py +306 -0
  23. nbkp-0.1.0/nbkp/sync/runner.py +510 -0
  24. nbkp-0.1.0/nbkp/sync/symlink.py +92 -0
  25. nbkp-0.1.0/nbkp/templates/__init__.py +0 -0
  26. nbkp-0.1.0/nbkp/templates/backup.sh.j2 +178 -0
  27. nbkp-0.1.0/nbkp/testkit/__init__.py +1 -0
  28. nbkp-0.1.0/nbkp/testkit/docker.py +310 -0
  29. nbkp-0.1.0/nbkp/testkit/dockerbuild/Dockerfile +22 -0
  30. nbkp-0.1.0/nbkp/testkit/dockerbuild/Dockerfile.btrfs-local-test +18 -0
  31. nbkp-0.1.0/nbkp/testkit/dockerbuild/btrfs-local-entrypoint.sh +14 -0
  32. nbkp-0.1.0/nbkp/testkit/dockerbuild/entrypoint.sh +30 -0
  33. nbkp-0.1.0/nbkp/testkit/gen/__init__.py +1 -0
  34. nbkp-0.1.0/nbkp/testkit/gen/check.py +392 -0
  35. nbkp-0.1.0/nbkp/testkit/gen/config.py +164 -0
  36. nbkp-0.1.0/nbkp/testkit/gen/fs.py +229 -0
  37. nbkp-0.1.0/nbkp/testkit/gen/sync.py +119 -0
  38. nbkp-0.1.0/pyproject.toml +69 -0
nbkp-0.1.0/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
nbkp-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,188 @@
1
+ Metadata-Version: 2.4
2
+ Name: nbkp
3
+ Version: 0.1.0
4
+ 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.
5
+ License-Expression: Apache-2.0
6
+ License-File: LICENSE
7
+ Author: Sami Dalouche
8
+ Author-email: sami.dalouche@gmail.com
9
+ Requires-Python: >=3.14
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.14
12
+ Provides-Extra: docker
13
+ Requires-Dist: docker (>=7.0,<8.0) ; extra == "docker"
14
+ Requires-Dist: fabric (>=3.0,<4.0)
15
+ Requires-Dist: jinja2 (>=3.0,<4.0)
16
+ Requires-Dist: pydantic (>=2.12.5,<3.0.0)
17
+ Requires-Dist: pyyaml (>=6.0,<7.0)
18
+ Requires-Dist: typer (>=0.24.0,<1.0.0)
19
+ Description-Content-Type: text/markdown
20
+
21
+ # Nomad Backup (nbkp)
22
+
23
+ ![Stable Version](https://img.shields.io/pypi/v/nbkp?label=stable)
24
+ ![Pre-release Version](https://img.shields.io/github/v/release/iglootools/nbkp?label=pre-release&include_prereleases&sort=semver)
25
+ ![Python Versions](https://img.shields.io/pypi/pyversions/nbkp)
26
+ ![Download Stats](https://img.shields.io/pypi/dm/nbkp)
27
+ ![GitHub Stars](https://img.shields.io/github/stars/iglootools/nbkp)
28
+ ![License](https://img.shields.io/github/license/iglootools/nbkp)
29
+ ![CI Status](https://github.com/iglootools/nbkp/actions/workflows/test.yml/badge.svg?branch=main)
30
+
31
+ An rsync-based backup tool for nomadic setups where sources and destinations aren't always available — laptops on the move, removable drives,
32
+ home servers behind changing networks.
33
+
34
+ Sentinel files ensure backups only run when volumes are genuinely present, with optional btrfs or hard-link snapshots for point-in-time recovery.
35
+
36
+ [![asciicast](https://asciinema.org/a/km9UuWa5TGjy9ldg.svg)](https://asciinema.org/a/km9UuWa5TGjy9ldg)
37
+
38
+ ## Installation
39
+
40
+ See [docs/installation.md](https://github.com/iglootools/nbkp/blob/main/docs/installation.md).
41
+
42
+ ## Usage
43
+
44
+ See [docs/usage.md](https://github.com/iglootools/nbkp/blob/main/docs/usage.md).
45
+
46
+
47
+ ## Main Use Cases
48
+
49
+ The tool is primarily designed for the following backup scenarios:
50
+ - **Laptop to Server** — back up to your home server whenever you're on the home network
51
+ - **Laptop to External Drive** — back up to an external drive whenever it's connected
52
+ - **External Drive to Server** — replicate an external drive to your home server when both are available
53
+ - **Server to External Drive** — back up your home server to an external drive
54
+ - **Easy Setup** - pilot the backups from your laptop, minimal setup on the server (`rsync`, `btrfs`)
55
+
56
+ It replaces the rsync shell scripts you'd normally maintain, adding:
57
+ - **Volume detection** (through sentinel files) — only runs when sources and destinations are actually available
58
+ - **Btrfs and hard-link snapshots** — keeps point-in-time copies so a bad sync can't wipe good backups
59
+ - **Declarative config** — one YAML file describes all your backup pairs
60
+ - **Structured output** — human-readable for convenience and JSON output for scripting and automation
61
+
62
+ Full feature list: [docs/features.md](https://github.com/iglootools/nbkp/blob/main/docs/features.md).
63
+
64
+ ## Non-Goals
65
+
66
+ nbkp is designed around a single orchestrator (typically a laptop) that initiates all syncs.
67
+ It intentionally does not support multi-server topologies where data flows directly between remote servers, for several reasons:
68
+
69
+ - **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.
70
+ - **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.
71
+ - **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.
72
+
73
+ If you need server-to-server replication:
74
+ - **Install nbkp on one of the servers** and configure separate syncs from there, treating that server as the orchestrator.
75
+ - **Compile a standalone script** with `nbkp sh` and deploy it to the server — no Python or nbkp installation required on the target server.
76
+ - **Use tools designed for multi-server topologies**: check the [Similar Tools](#similar-tools) section for options that support enterpris-y / multi-host setups.
77
+
78
+ ## Philosophy
79
+
80
+ **Design Principles**
81
+ - Laptop-centric workflows
82
+ - Changing networks
83
+ - Drives being plugged/unplugged
84
+ - Backups happening when possible
85
+ - Not always-on infrastructure
86
+ - Personal homelab / Raspberry Pi setups
87
+
88
+ **Implementation Principles**
89
+
90
+ No custom storage format, protocol, or encryption — just proven tools composed together:
91
+ - **rsync + SSH** — handles the actual file transfer, locally or remotely
92
+ - **Plain directories** — files are stored as-is; restoring is just a copy
93
+ - **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
94
+ - **Hard-link snapshots (optional)** — alternative to btrfs snapshots, works on any filesystem that supports hard links, but less efficient and more fragile
95
+ - **cryptsetup (optional)** — full-volume encryption for backup destinations
96
+
97
+ **Nomad backup metaphor**
98
+
99
+ A nomad:
100
+ - Moves between places
101
+ - Sets up temporary camp
102
+ - Carries essential belongings
103
+ - Adapts to environment
104
+ - Relies on what is present
105
+
106
+ Which maps to:
107
+ - Laptop
108
+ - External drive
109
+ - Home server
110
+ - Network availability
111
+ - Mount detection
112
+
113
+ ## Contribute
114
+
115
+ Practical information:
116
+ - [docs/setup-development-environment.md](https://github.com/iglootools/nbkp/blob/main/docs/setup-development-environment.md) — development setup
117
+ - [docs/building-and-testing.md](https://github.com/iglootools/nbkp/blob/main/docs/building-and-testing.md) — running tests and checks
118
+ - [docs/releasing-and-publishing.md](https://github.com/iglootools/nbkp/blob/main/docs/releasing-and-publishing.md) — releases and PyPI publishing
119
+ - [docs/conventions.md](https://github.com/iglootools/nbkp/blob/main/docs/conventions.md) — coding conventions and guidelines
120
+
121
+ Conceptual information:
122
+ - [docs/concepts.md](https://github.com/iglootools/nbkp/blob/main/docs/concepts.md) - key concepts and terminology
123
+ - [docs/architecture.md](https://github.com/iglootools/nbkp/blob/main/docs/architecture.md) - architecture overview
124
+
125
+ ## Resources
126
+ - [Releases](https://pypi.org/project/nbkp/#history)
127
+ - [Issue Tracker](https://github.com/iglootools/nbkp/issues)
128
+
129
+ ## Related Projects
130
+
131
+ ### Dependencies
132
+ - [rsync](https://rsync.samba.org/) — the underlying file synchronization tool
133
+ - [btrfs](https://btrfs.wiki.kernel.org/index.php/Main_Page) — for space-efficient point-in-time copies via copy-on-write
134
+ - [cryptsetup](https://gitlab.com/cryptsetup/cryptsetup) — for full-volume encryption
135
+ - [typer](https://typer.tiangolo.com/) — for building the CLI interface
136
+ - [pydantic](https://pydantic.dev/) — for data modeling and validation
137
+
138
+ ### Similar Tools
139
+
140
+ 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.
141
+ 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.
142
+
143
+ #### Rsync-related
144
+
145
+ - **[rsnapshot](https://rsnapshot.org/)** — 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.
146
+ - **[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.
147
+ - **[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.
148
+ - **[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.
149
+ - **[Dirvish](https://dirvish.org/)** — rotating network backup system using rsync + hard links. Oriented toward server-pull workflows; no removable-drive detection or btrfs support.
150
+ - **[Duplicity](https://duplicity.us/)** — GPG-encrypted tar volumes with librsync incremental transfers. Not browsable as plain directories; full+incremental chain model; no btrfs integration.
151
+
152
+ #### Deduplicating
153
+
154
+ - **[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.
155
+ - **[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.
156
+ - **[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.
157
+
158
+ #### Btrfs / snapshot-focused
159
+
160
+ - **[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.
161
+ - **[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.
162
+ - **[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.
163
+
164
+ #### Continuous / real-time
165
+
166
+ - **[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.
167
+ - **[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.
168
+
169
+ #### Cloud / multi-backend
170
+
171
+ - **[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.
172
+
173
+ #### Bidirectional sync
174
+
175
+ - **[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.
176
+
177
+ #### Enterprise / multi-host
178
+
179
+ - **[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.
180
+ - **[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.
181
+ - **[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.
182
+ - **[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.
183
+
184
+ ## License
185
+
186
+ This project is licensed under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0) - see the LICENSE file for details.
187
+
188
+
nbkp-0.1.0/README.md ADDED
@@ -0,0 +1,167 @@
1
+ # Nomad Backup (nbkp)
2
+
3
+ ![Stable Version](https://img.shields.io/pypi/v/nbkp?label=stable)
4
+ ![Pre-release Version](https://img.shields.io/github/v/release/iglootools/nbkp?label=pre-release&include_prereleases&sort=semver)
5
+ ![Python Versions](https://img.shields.io/pypi/pyversions/nbkp)
6
+ ![Download Stats](https://img.shields.io/pypi/dm/nbkp)
7
+ ![GitHub Stars](https://img.shields.io/github/stars/iglootools/nbkp)
8
+ ![License](https://img.shields.io/github/license/iglootools/nbkp)
9
+ ![CI Status](https://github.com/iglootools/nbkp/actions/workflows/test.yml/badge.svg?branch=main)
10
+
11
+ An rsync-based backup tool for nomadic setups where sources and destinations aren't always available — laptops on the move, removable drives,
12
+ home servers behind changing networks.
13
+
14
+ Sentinel files ensure backups only run when volumes are genuinely present, with optional btrfs or hard-link snapshots for point-in-time recovery.
15
+
16
+ [![asciicast](https://asciinema.org/a/km9UuWa5TGjy9ldg.svg)](https://asciinema.org/a/km9UuWa5TGjy9ldg)
17
+
18
+ ## Installation
19
+
20
+ See [docs/installation.md](https://github.com/iglootools/nbkp/blob/main/docs/installation.md).
21
+
22
+ ## Usage
23
+
24
+ See [docs/usage.md](https://github.com/iglootools/nbkp/blob/main/docs/usage.md).
25
+
26
+
27
+ ## Main Use Cases
28
+
29
+ The tool is primarily designed for the following backup scenarios:
30
+ - **Laptop to Server** — back up to your home server whenever you're on the home network
31
+ - **Laptop to External Drive** — back up to an external drive whenever it's connected
32
+ - **External Drive to Server** — replicate an external drive to your home server when both are available
33
+ - **Server to External Drive** — back up your home server to an external drive
34
+ - **Easy Setup** - pilot the backups from your laptop, minimal setup on the server (`rsync`, `btrfs`)
35
+
36
+ It replaces the rsync shell scripts you'd normally maintain, adding:
37
+ - **Volume detection** (through sentinel files) — only runs when sources and destinations are actually available
38
+ - **Btrfs and hard-link snapshots** — keeps point-in-time copies so a bad sync can't wipe good backups
39
+ - **Declarative config** — one YAML file describes all your backup pairs
40
+ - **Structured output** — human-readable for convenience and JSON output for scripting and automation
41
+
42
+ Full feature list: [docs/features.md](https://github.com/iglootools/nbkp/blob/main/docs/features.md).
43
+
44
+ ## Non-Goals
45
+
46
+ nbkp is designed around a single orchestrator (typically a laptop) that initiates all syncs.
47
+ It intentionally does not support multi-server topologies where data flows directly between remote servers, for several reasons:
48
+
49
+ - **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.
50
+ - **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.
51
+ - **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.
52
+
53
+ If you need server-to-server replication:
54
+ - **Install nbkp on one of the servers** and configure separate syncs from there, treating that server as the orchestrator.
55
+ - **Compile a standalone script** with `nbkp sh` and deploy it to the server — no Python or nbkp installation required on the target server.
56
+ - **Use tools designed for multi-server topologies**: check the [Similar Tools](#similar-tools) section for options that support enterpris-y / multi-host setups.
57
+
58
+ ## Philosophy
59
+
60
+ **Design Principles**
61
+ - Laptop-centric workflows
62
+ - Changing networks
63
+ - Drives being plugged/unplugged
64
+ - Backups happening when possible
65
+ - Not always-on infrastructure
66
+ - Personal homelab / Raspberry Pi setups
67
+
68
+ **Implementation Principles**
69
+
70
+ No custom storage format, protocol, or encryption — just proven tools composed together:
71
+ - **rsync + SSH** — handles the actual file transfer, locally or remotely
72
+ - **Plain directories** — files are stored as-is; restoring is just a copy
73
+ - **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
74
+ - **Hard-link snapshots (optional)** — alternative to btrfs snapshots, works on any filesystem that supports hard links, but less efficient and more fragile
75
+ - **cryptsetup (optional)** — full-volume encryption for backup destinations
76
+
77
+ **Nomad backup metaphor**
78
+
79
+ A nomad:
80
+ - Moves between places
81
+ - Sets up temporary camp
82
+ - Carries essential belongings
83
+ - Adapts to environment
84
+ - Relies on what is present
85
+
86
+ Which maps to:
87
+ - Laptop
88
+ - External drive
89
+ - Home server
90
+ - Network availability
91
+ - Mount detection
92
+
93
+ ## Contribute
94
+
95
+ Practical information:
96
+ - [docs/setup-development-environment.md](https://github.com/iglootools/nbkp/blob/main/docs/setup-development-environment.md) — development setup
97
+ - [docs/building-and-testing.md](https://github.com/iglootools/nbkp/blob/main/docs/building-and-testing.md) — running tests and checks
98
+ - [docs/releasing-and-publishing.md](https://github.com/iglootools/nbkp/blob/main/docs/releasing-and-publishing.md) — releases and PyPI publishing
99
+ - [docs/conventions.md](https://github.com/iglootools/nbkp/blob/main/docs/conventions.md) — coding conventions and guidelines
100
+
101
+ Conceptual information:
102
+ - [docs/concepts.md](https://github.com/iglootools/nbkp/blob/main/docs/concepts.md) - key concepts and terminology
103
+ - [docs/architecture.md](https://github.com/iglootools/nbkp/blob/main/docs/architecture.md) - architecture overview
104
+
105
+ ## Resources
106
+ - [Releases](https://pypi.org/project/nbkp/#history)
107
+ - [Issue Tracker](https://github.com/iglootools/nbkp/issues)
108
+
109
+ ## Related Projects
110
+
111
+ ### Dependencies
112
+ - [rsync](https://rsync.samba.org/) — the underlying file synchronization tool
113
+ - [btrfs](https://btrfs.wiki.kernel.org/index.php/Main_Page) — for space-efficient point-in-time copies via copy-on-write
114
+ - [cryptsetup](https://gitlab.com/cryptsetup/cryptsetup) — for full-volume encryption
115
+ - [typer](https://typer.tiangolo.com/) — for building the CLI interface
116
+ - [pydantic](https://pydantic.dev/) — for data modeling and validation
117
+
118
+ ### Similar Tools
119
+
120
+ 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.
121
+ 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.
122
+
123
+ #### Rsync-related
124
+
125
+ - **[rsnapshot](https://rsnapshot.org/)** — 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.
126
+ - **[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.
127
+ - **[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.
128
+ - **[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.
129
+ - **[Dirvish](https://dirvish.org/)** — rotating network backup system using rsync + hard links. Oriented toward server-pull workflows; no removable-drive detection or btrfs support.
130
+ - **[Duplicity](https://duplicity.us/)** — GPG-encrypted tar volumes with librsync incremental transfers. Not browsable as plain directories; full+incremental chain model; no btrfs integration.
131
+
132
+ #### Deduplicating
133
+
134
+ - **[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.
135
+ - **[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.
136
+ - **[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.
137
+
138
+ #### Btrfs / snapshot-focused
139
+
140
+ - **[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.
141
+ - **[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.
142
+ - **[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.
143
+
144
+ #### Continuous / real-time
145
+
146
+ - **[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.
147
+ - **[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.
148
+
149
+ #### Cloud / multi-backend
150
+
151
+ - **[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.
152
+
153
+ #### Bidirectional sync
154
+
155
+ - **[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.
156
+
157
+ #### Enterprise / multi-host
158
+
159
+ - **[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.
160
+ - **[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.
161
+ - **[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.
162
+ - **[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.
163
+
164
+ ## License
165
+
166
+ This project is licensed under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0) - see the LICENSE file for details.
167
+
@@ -0,0 +1,3 @@
1
+ """Nomad Backup (NBKP) - An rsync-based backup tool."""
2
+
3
+ __version__ = "0.1.0"