rangler 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.
- rangler-0.1.0/.github/workflows/publish.yml +83 -0
- rangler-0.1.0/.gitignore +19 -0
- rangler-0.1.0/CLAUDE.md +126 -0
- rangler-0.1.0/LICENSE +202 -0
- rangler-0.1.0/NOTICE +8 -0
- rangler-0.1.0/PKG-INFO +222 -0
- rangler-0.1.0/README.md +210 -0
- rangler-0.1.0/pyproject.toml +51 -0
- rangler-0.1.0/src/rangler/__init__.py +6 -0
- rangler-0.1.0/src/rangler/__main__.py +9 -0
- rangler-0.1.0/src/rangler/backup.py +327 -0
- rangler-0.1.0/src/rangler/cli.py +250 -0
- rangler-0.1.0/src/rangler/config.py +286 -0
- rangler-0.1.0/src/rangler/discovery.py +102 -0
- rangler-0.1.0/src/rangler/locking.py +51 -0
- rangler-0.1.0/src/rangler/notify.py +91 -0
- rangler-0.1.0/src/rangler/paths.py +163 -0
- rangler-0.1.0/src/rangler/rclone.py +213 -0
- rangler-0.1.0/src/rangler/runtimestate.py +96 -0
- rangler-0.1.0/src/rangler/schedule.py +230 -0
- rangler-0.1.0/src/rangler/summary.py +75 -0
- rangler-0.1.0/src/rangler/targets.py +106 -0
- rangler-0.1.0/tests/__init__.py +0 -0
- rangler-0.1.0/tests/conftest.py +129 -0
- rangler-0.1.0/tests/integration/__init__.py +0 -0
- rangler-0.1.0/tests/integration/test_backup_local_remote.py +197 -0
- rangler-0.1.0/tests/integration/test_cli.py +406 -0
- rangler-0.1.0/tests/unit/__init__.py +0 -0
- rangler-0.1.0/tests/unit/test_backup.py +261 -0
- rangler-0.1.0/tests/unit/test_config.py +201 -0
- rangler-0.1.0/tests/unit/test_discovery.py +133 -0
- rangler-0.1.0/tests/unit/test_entrypoint.py +20 -0
- rangler-0.1.0/tests/unit/test_locking.py +49 -0
- rangler-0.1.0/tests/unit/test_notify_message.py +125 -0
- rangler-0.1.0/tests/unit/test_paths.py +111 -0
- rangler-0.1.0/tests/unit/test_rclone_command.py +153 -0
- rangler-0.1.0/tests/unit/test_runtimestate.py +54 -0
- rangler-0.1.0/tests/unit/test_schedule_plist.py +119 -0
- rangler-0.1.0/tests/unit/test_summary.py +95 -0
- rangler-0.1.0/tests/unit/test_targets.py +85 -0
- rangler-0.1.0/uv.lock +124 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Publishes rangler to PyPI when a GitHub release is published.
|
|
2
|
+
#
|
|
3
|
+
# Uses PyPI trusted publishing (OIDC), so no API token is stored: the workflow
|
|
4
|
+
# exchanges a short-lived GitHub identity token for an upload token. This
|
|
5
|
+
# requires a trusted publisher to be configured on PyPI for the project (see
|
|
6
|
+
# below) and the `pypi` environment to exist on the repository.
|
|
7
|
+
#
|
|
8
|
+
# PyPI trusted publisher configuration (one-time, on pypi.org):
|
|
9
|
+
# - Project: rangler
|
|
10
|
+
# - Owner: johngrimes
|
|
11
|
+
# - Repository: rangler
|
|
12
|
+
# - Workflow: publish.yml
|
|
13
|
+
# - Environment: pypi
|
|
14
|
+
#
|
|
15
|
+
# Author: John Grimes.
|
|
16
|
+
|
|
17
|
+
name: Publish
|
|
18
|
+
|
|
19
|
+
on:
|
|
20
|
+
release:
|
|
21
|
+
types: [published]
|
|
22
|
+
# Allow a manual publish from the Actions tab or `gh workflow run`. Dispatch
|
|
23
|
+
# against a version tag (for example `v0.1.0`) so the verify step below can
|
|
24
|
+
# confirm the ref matches the packaged version.
|
|
25
|
+
workflow_dispatch:
|
|
26
|
+
|
|
27
|
+
jobs:
|
|
28
|
+
publish:
|
|
29
|
+
name: Build and publish to PyPI
|
|
30
|
+
runs-on: ubuntu-latest
|
|
31
|
+
|
|
32
|
+
# Scope the OIDC credential to a dedicated environment so the publish step
|
|
33
|
+
# can be gated with required reviewers or branch rules if desired.
|
|
34
|
+
environment:
|
|
35
|
+
name: pypi
|
|
36
|
+
url: https://pypi.org/project/rangler/
|
|
37
|
+
|
|
38
|
+
permissions:
|
|
39
|
+
# Required for trusted publishing to mint the OIDC token.
|
|
40
|
+
id-token: write
|
|
41
|
+
contents: read
|
|
42
|
+
|
|
43
|
+
steps:
|
|
44
|
+
- name: Checkout
|
|
45
|
+
uses: actions/checkout@v7
|
|
46
|
+
|
|
47
|
+
- name: Install uv
|
|
48
|
+
# Pin to a full version tag: from v8.0.0 onwards setup-uv publishes
|
|
49
|
+
# immutable, full-version tags only and no longer moves a `v8` major
|
|
50
|
+
# tag, so `@v8` cannot be resolved.
|
|
51
|
+
uses: astral-sh/setup-uv@v8.2.0
|
|
52
|
+
|
|
53
|
+
- name: Install Python
|
|
54
|
+
run: uv python install
|
|
55
|
+
|
|
56
|
+
# Guard against publishing a mismatched version: PyPI uploads are
|
|
57
|
+
# irreversible (a version can never be re-uploaded), so a tag that does
|
|
58
|
+
# not match the packaged version must abort before anything is built.
|
|
59
|
+
- name: Verify tag matches package version
|
|
60
|
+
# For a release event the tag comes from the release payload; for a
|
|
61
|
+
# manual dispatch it comes from the ref the workflow was run against, so
|
|
62
|
+
# a dispatch must target a version tag rather than a branch.
|
|
63
|
+
env:
|
|
64
|
+
TAG: ${{ github.event.release.tag_name || github.ref_name }}
|
|
65
|
+
run: |
|
|
66
|
+
version="$(python3 -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")"
|
|
67
|
+
tag="${TAG#v}"
|
|
68
|
+
if [ "$tag" != "$version" ]; then
|
|
69
|
+
echo "::error::Tag '${TAG}' does not match pyproject version '${version}'."
|
|
70
|
+
exit 1
|
|
71
|
+
fi
|
|
72
|
+
echo "Tag '${TAG}' matches package version '${version}'."
|
|
73
|
+
|
|
74
|
+
- name: Build
|
|
75
|
+
run: uv build
|
|
76
|
+
|
|
77
|
+
# Confirm the freshly built wheel installs and its entry point runs before
|
|
78
|
+
# anything is uploaded, catching missing files or a broken console script.
|
|
79
|
+
- name: Smoke test (wheel)
|
|
80
|
+
run: uv run --isolated --no-project --with dist/*.whl -- rangler --version
|
|
81
|
+
|
|
82
|
+
- name: Publish
|
|
83
|
+
run: uv publish
|
rangler-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Python bytecode and caches.
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
|
|
5
|
+
# Virtual environments.
|
|
6
|
+
.venv/
|
|
7
|
+
|
|
8
|
+
# Test and coverage artifacts.
|
|
9
|
+
.coverage
|
|
10
|
+
.pytest_cache/
|
|
11
|
+
htmlcov/
|
|
12
|
+
|
|
13
|
+
# Linter caches.
|
|
14
|
+
.ruff_cache/
|
|
15
|
+
|
|
16
|
+
# Build outputs.
|
|
17
|
+
dist/
|
|
18
|
+
build/
|
|
19
|
+
*.egg-info/
|
rangler-0.1.0/CLAUDE.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# rangler
|
|
2
|
+
|
|
3
|
+
rangler is a macOS command-line tool that backs up a single user's home
|
|
4
|
+
directory to an rclone remote: an explicit list of configured paths (under
|
|
5
|
+
`files/`) and auto-discovered project `.local` directories (under `locals/`),
|
|
6
|
+
namespaced by hostname, with versioned deletes and optional scheduling.
|
|
7
|
+
|
|
8
|
+
## Constitution
|
|
9
|
+
|
|
10
|
+
### Core Principles
|
|
11
|
+
|
|
12
|
+
#### I. Data safety is non-negotiable
|
|
13
|
+
|
|
14
|
+
rangler is trusted with the only copy of a user's data, so an accidental local
|
|
15
|
+
write or an unrecoverable remote delete is the worst possible failure.
|
|
16
|
+
|
|
17
|
+
- Backups are one-way (local to remote). rangler MUST NOT write to the local
|
|
18
|
+
filesystem except its own config (`~/.config/rangler/`), logs
|
|
19
|
+
(`~/Library/Logs/rangler/`), runtime state and lock
|
|
20
|
+
(`~/.local/state/rangler/`), and its LaunchAgent plist
|
|
21
|
+
(`~/Library/LaunchAgents/au.id.grimes.john.rangler.plist`).
|
|
22
|
+
- rangler MUST NOT hard-delete remote data. Prior copies of files that are
|
|
23
|
+
changed or removed locally MUST be moved into the timestamped
|
|
24
|
+
`_versions/<run-timestamp>/` area before being overwritten.
|
|
25
|
+
- rangler MUST only ever write under `<base>/<host>/`; other hosts' trees MUST
|
|
26
|
+
remain untouched.
|
|
27
|
+
- Every configured path and scan root MUST resolve (after `~` expansion) to a
|
|
28
|
+
location under `$HOME`. A non-home entry is a hard configuration error and is
|
|
29
|
+
never backed up.
|
|
30
|
+
|
|
31
|
+
#### II. Fail safe, fail loud
|
|
32
|
+
|
|
33
|
+
A backup tool earns trust by never failing silently and never half-doing the
|
|
34
|
+
job.
|
|
35
|
+
|
|
36
|
+
- A run MUST verify that rclone is available and the configured remote is
|
|
37
|
+
reachable before transferring anything; otherwise it aborts before making any
|
|
38
|
+
change, prints actionable guidance, and exits non-zero.
|
|
39
|
+
- Targets MUST be processed independently: a per-target failure is recorded and
|
|
40
|
+
the run continues with the remaining targets; any failed target makes the run
|
|
41
|
+
exit non-zero.
|
|
42
|
+
- Overlapping runs MUST be prevented by a lock. A second concurrent run exits
|
|
43
|
+
cleanly and records that it was skipped, never interleaving writes to the
|
|
44
|
+
remote.
|
|
45
|
+
- The user MUST be kept informed of system status: per-target start and finish,
|
|
46
|
+
a final run summary, a written per-run log, desktop notifications per the
|
|
47
|
+
configured policy, and a `status` command reporting schedule state and the
|
|
48
|
+
last run's result. Silent success and silent failure are both defects.
|
|
49
|
+
|
|
50
|
+
#### III. The remote layout is a stable contract
|
|
51
|
+
|
|
52
|
+
Restore is performed manually against the structure rangler writes, so that
|
|
53
|
+
structure is a public contract, not an implementation detail.
|
|
54
|
+
|
|
55
|
+
- The destination layout MUST remain stable: hostname namespacing; the `files/`,
|
|
56
|
+
`locals/`, and `_versions/<timestamp>/` sections; and the home-relative
|
|
57
|
+
mapping rules that place each source under them.
|
|
58
|
+
- `_versions/` MUST remain a sibling of `files/` and `locals/`, never nested
|
|
59
|
+
inside a destination, to satisfy rclone's `--backup-dir` constraint.
|
|
60
|
+
- Any change that breaks restore compatibility with data already on a remote
|
|
61
|
+
MUST be treated as a breaking change: called out explicitly and documented,
|
|
62
|
+
never shipped silently.
|
|
63
|
+
|
|
64
|
+
#### IV. Radical simplicity, minimal dependencies
|
|
65
|
+
|
|
66
|
+
Complexity is a cost that must be justified; the simplest design that meets the
|
|
67
|
+
requirement wins.
|
|
68
|
+
|
|
69
|
+
- Click is the only permitted runtime dependency. Everything else MUST come from
|
|
70
|
+
the Python standard library, and rangler MUST shell out to the user-installed
|
|
71
|
+
rclone binary rather than embedding rclone as a library.
|
|
72
|
+
- Introducing a new runtime dependency, a daemon, a database, or a built-in
|
|
73
|
+
encryption layer is prohibited unless it is justified against a simpler
|
|
74
|
+
alternative and explicitly agreed.
|
|
75
|
+
- When multiple approaches work, choose the one with the fewest moving parts;
|
|
76
|
+
aggressively remove abstractions that are not strictly necessary.
|
|
77
|
+
|
|
78
|
+
#### V. Pure functions, tested first
|
|
79
|
+
|
|
80
|
+
The logic must be testable without touching the network, the filesystem, or
|
|
81
|
+
launchd.
|
|
82
|
+
|
|
83
|
+
- Test-driven development is mandatory: write failing tests that define the
|
|
84
|
+
behaviour, add minimal stubs, confirm the tests fail for the right reason,
|
|
85
|
+
then implement until they pass.
|
|
86
|
+
- All behaviour MUST live in standalone functions operating on immutable
|
|
87
|
+
(frozen dataclass) data shapes; behavioural classes are not used. Side effects
|
|
88
|
+
- subprocess, filesystem, `launchctl`, `osascript` - MUST be confined to thin
|
|
89
|
+
wrappers and the CLI layer.
|
|
90
|
+
- Unit tests MUST mock the rclone subprocess and exercise every branch. A small
|
|
91
|
+
set of integration tests run the real rclone binary against a local-path
|
|
92
|
+
remote and are skipped when rclone is absent.
|
|
93
|
+
|
|
94
|
+
### Additional constraints
|
|
95
|
+
|
|
96
|
+
- **Platform and scope**: macOS, single user. Scheduling uses launchd
|
|
97
|
+
LaunchAgents; cross-platform scheduling is out of scope. Restore is out of
|
|
98
|
+
scope as a command - it is documented as manual rclone steps against the
|
|
99
|
+
remote layout.
|
|
100
|
+
- **Configuration**: a single TOML file at `~/.config/rangler/config.toml`,
|
|
101
|
+
validated with clear errors. Unknown keys are reported as warnings (typo
|
|
102
|
+
protection) rather than aborting.
|
|
103
|
+
- **Trust boundaries**: rclone installation, remote configuration, and any
|
|
104
|
+
encryption (for example an rclone crypt remote) are the user's
|
|
105
|
+
responsibility. rangler validates these but never installs or configures
|
|
106
|
+
rclone and adds no encryption of its own.
|
|
107
|
+
- **Symlinks**: rangler follows symlinks so that symlinked dotfiles are stored
|
|
108
|
+
as content rather than dangling link references; excludes are the mechanism
|
|
109
|
+
for preventing unwanted bulk.
|
|
110
|
+
|
|
111
|
+
### Development workflow and quality gates
|
|
112
|
+
|
|
113
|
+
- **Tooling**: uv manages the project, its Python version, and its virtual
|
|
114
|
+
environment. ruff lints and formats. Python files use snake_case (the
|
|
115
|
+
lowerCamelCase file-naming rule is TypeScript-only).
|
|
116
|
+
- **Documentation**: every public function carries a complete docstring -
|
|
117
|
+
purpose, parameters, return value, exceptions, and an example for non-trivial
|
|
118
|
+
functions. New source files are authored by John Grimes.
|
|
119
|
+
- **Definition of done**: the full pytest suite, `ruff check`, and
|
|
120
|
+
`ruff format --check` MUST pass, and the change MUST be demonstrated to work
|
|
121
|
+
(for example via a dry run against a local-path remote) before it is called
|
|
122
|
+
complete.
|
|
123
|
+
- **Reviewability**: every change MUST be checkable against these principles. A
|
|
124
|
+
reviewer should be able to point to the principle a change violates without
|
|
125
|
+
ambiguity. An unavoidable violation MUST be documented and agreed, never
|
|
126
|
+
slipped in.
|
rangler-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
rangler-0.1.0/NOTICE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
rangler
|
|
2
|
+
|
|
3
|
+
Copyright © 2026 John Grimes.
|
|
4
|
+
|
|
5
|
+
This product is licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this product except in compliance with the License. A copy of
|
|
7
|
+
the License is provided in the LICENSE file accompanying this product, and is
|
|
8
|
+
also available at http://www.apache.org/licenses/LICENSE-2.0.
|
rangler-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rangler
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: macOS home-directory backup to an rclone remote, with versioning and scheduling.
|
|
5
|
+
Author: John Grimes
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
License-File: NOTICE
|
|
9
|
+
Requires-Python: >=3.13
|
|
10
|
+
Requires-Dist: click==8.4.1
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
# rangler
|
|
14
|
+
|
|
15
|
+
rangler is a macOS command-line tool that backs up a single user's home
|
|
16
|
+
directory to an [rclone](https://rclone.org/) remote. It mirrors an explicit
|
|
17
|
+
list of configured paths (under `files/`) and auto-discovered project `.local`
|
|
18
|
+
directories (under `locals/`), namespaces everything by hostname, keeps prior
|
|
19
|
+
versions of changed and deleted files, and can run unattended on a schedule.
|
|
20
|
+
|
|
21
|
+
Backups are one-way (local to remote). rangler never writes to your local
|
|
22
|
+
filesystem except its own configuration, logs, runtime state, and its
|
|
23
|
+
LaunchAgent. It shells out to the `rclone` binary you have installed; it does not
|
|
24
|
+
install or configure rclone, and it adds no encryption of its own (use an rclone
|
|
25
|
+
crypt remote if you want that).
|
|
26
|
+
|
|
27
|
+
## Requirements
|
|
28
|
+
|
|
29
|
+
- macOS, single user.
|
|
30
|
+
- [rclone](https://rclone.org/) installed and at least one remote configured.
|
|
31
|
+
- Python 3.13+ and [uv](https://docs.astral.sh/uv/) for installation from source.
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
```console
|
|
36
|
+
brew install rclone
|
|
37
|
+
rclone config # create a remote, e.g. a `local` remote named `backup`
|
|
38
|
+
uv tool install --editable . # or run ad hoc with: uv run rangler ...
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Configuration
|
|
42
|
+
|
|
43
|
+
rangler reads a single TOML file at `~/.config/rangler/config.toml`. Scaffold a
|
|
44
|
+
starter file with `rangler init`, then edit it. Every path must live under your
|
|
45
|
+
home directory.
|
|
46
|
+
|
|
47
|
+
| Key | Type | Default | Notes |
|
|
48
|
+
| ------------- | --------------- | ------------ | --------------------------------------------------------- |
|
|
49
|
+
| `remote_base` | string | (required) | rclone remote in `name:path` form, e.g. `backup:rangler`. |
|
|
50
|
+
| `paths` | array of string | `[]` | Explicit paths under `$HOME` to back up. `~` is expanded. |
|
|
51
|
+
| `scan_roots` | array of string | `["~/Code"]` | Roots scanned for `.local` directories. |
|
|
52
|
+
| `max_depth` | integer | `4` | Maximum descent depth under each scan root. |
|
|
53
|
+
| `excludes` | array of string | see below | rclone filter patterns applied to every target. |
|
|
54
|
+
| `interval` | string | `"6h"` | Schedule cadence as a duration: `30m`, `6h`, `1d`. |
|
|
55
|
+
| `notify` | string | `"failure"` | Desktop notifications: `failure`, `always`, or `never`. |
|
|
56
|
+
|
|
57
|
+
Default `excludes`: `node_modules/**`, `.git/**`, `.DS_Store`, `*.log`,
|
|
58
|
+
`.cache/**`, `__pycache__/**`. At least one of `paths` or `scan_roots` must be
|
|
59
|
+
non-empty. Unknown keys are reported as warnings (typo protection) rather than
|
|
60
|
+
aborting.
|
|
61
|
+
|
|
62
|
+
## Usage
|
|
63
|
+
|
|
64
|
+
### `rangler init`
|
|
65
|
+
|
|
66
|
+
Scaffold a starter `config.toml`. Does nothing if one already exists unless you
|
|
67
|
+
pass `--force` to overwrite it.
|
|
68
|
+
|
|
69
|
+
```console
|
|
70
|
+
rangler init
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### `rangler check`
|
|
74
|
+
|
|
75
|
+
Validate the configuration, confirm rclone is present and the remote is
|
|
76
|
+
reachable, and print the full resolved target list (each source and its computed
|
|
77
|
+
destination) without transferring anything. Exits `0` when valid, `2` when the
|
|
78
|
+
configuration is invalid, and `3` when rclone is missing or the remote is
|
|
79
|
+
unreachable.
|
|
80
|
+
|
|
81
|
+
```console
|
|
82
|
+
rangler check
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### `rangler run`
|
|
86
|
+
|
|
87
|
+
Back up every resolved target. Each explicit path is mirrored to
|
|
88
|
+
`<remote_base>/<hostname>/files/<path-relative-to-home>`. Symlinks are followed
|
|
89
|
+
so symlinked dotfiles are stored as content. Prior copies of changed or deleted
|
|
90
|
+
files are moved into `<remote_base>/<hostname>/_versions/<run-timestamp>/...`
|
|
91
|
+
rather than being hard-deleted. Each run prints per-target progress and a final
|
|
92
|
+
summary, and writes a timestamped log to `~/Library/Logs/rangler/`.
|
|
93
|
+
|
|
94
|
+
```console
|
|
95
|
+
rangler run # perform the backup
|
|
96
|
+
rangler run --dry-run # report intended changes without writing to the remote
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
A configured path that does not exist on this machine is reported as skipped and
|
|
100
|
+
does not fail the run (paths legitimately differ across machines). A path that
|
|
101
|
+
exists but errors during transfer is recorded as a failed target; the run
|
|
102
|
+
continues with the others and exits non-zero. Overlapping runs are prevented by a
|
|
103
|
+
lock: a second concurrent run exits cleanly with `skipped: already running`.
|
|
104
|
+
|
|
105
|
+
### Auto-discovery of `.local` directories
|
|
106
|
+
|
|
107
|
+
Beyond the explicit `paths` list, rangler scans each entry in `scan_roots`
|
|
108
|
+
(default `~/Code`) for project `.local` directories down to `max_depth` (default
|
|
109
|
+
4). Each discovered `<root>/.../project/.local` is mirrored to
|
|
110
|
+
`<remote_base>/<hostname>/locals/<project-path-relative-to-home>` - the `.local`
|
|
111
|
+
segment itself is dropped. For example, `~/Code/pathling/.local` is backed up to
|
|
112
|
+
`locals/Code/pathling`.
|
|
113
|
+
|
|
114
|
+
Discovery deliberately skips:
|
|
115
|
+
|
|
116
|
+
- the XDG `~/.local` directory (it shares the name but is not a project scratch
|
|
117
|
+
directory);
|
|
118
|
+
- `.Trash` and any directory named by an exclude pattern (such as `node_modules`
|
|
119
|
+
or `.git`), which are pruned without being descended into.
|
|
120
|
+
|
|
121
|
+
If the same directory is both discovered and listed explicitly in `paths`, it is
|
|
122
|
+
backed up once, with the explicit `files/` mapping taking precedence. Run
|
|
123
|
+
`rangler check` to preview the full resolved target list - explicit and
|
|
124
|
+
discovered alike - before backing up.
|
|
125
|
+
|
|
126
|
+
### Scheduling (`schedule` / `unschedule` / `status`)
|
|
127
|
+
|
|
128
|
+
rangler can run unattended via a macOS LaunchAgent that fires on a fixed
|
|
129
|
+
interval and survives reboot.
|
|
130
|
+
|
|
131
|
+
```console
|
|
132
|
+
rangler schedule --every 30m # install and load the agent (defaults to config interval)
|
|
133
|
+
rangler status # report whether scheduling is active and the last run
|
|
134
|
+
rangler unschedule # unload and remove the agent
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
`schedule` writes a LaunchAgent plist to
|
|
138
|
+
`~/Library/LaunchAgents/au.id.grimes.john.rangler.plist` and loads it with `launchctl
|
|
139
|
+
bootstrap`; re-running it replaces any existing agent. `--every` accepts a
|
|
140
|
+
duration (`30m`, `6h`, `1d`) and defaults to the `interval` from the config.
|
|
141
|
+
`unschedule` is idempotent: it succeeds even if nothing was installed. `status`
|
|
142
|
+
reports the active interval and the time and result of the last run (read from
|
|
143
|
+
`~/.local/state/rangler/last-run.json`).
|
|
144
|
+
|
|
145
|
+
You can confirm the loaded job directly with launchctl:
|
|
146
|
+
|
|
147
|
+
```console
|
|
148
|
+
launchctl print gui/$(id -u)/au.id.grimes.john.rangler
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Notifications
|
|
152
|
+
|
|
153
|
+
For unattended runs, rangler can raise a macOS desktop notification at run
|
|
154
|
+
completion. The `notify` config key controls when:
|
|
155
|
+
|
|
156
|
+
- `failure` (default): notify only when one or more targets failed.
|
|
157
|
+
- `always`: notify on every completed run, success or failure.
|
|
158
|
+
- `never`: stay silent.
|
|
159
|
+
|
|
160
|
+
Notifications fire for real runs (manual or scheduled); a `--dry-run` preview is
|
|
161
|
+
always silent.
|
|
162
|
+
|
|
163
|
+
## Remote layout
|
|
164
|
+
|
|
165
|
+
Given `remote_base = "backup:rangler"` and hostname `mymac`:
|
|
166
|
+
|
|
167
|
+
```text
|
|
168
|
+
backup:rangler/
|
|
169
|
+
└── mymac/ # Hostname segment.
|
|
170
|
+
├── files/ # Explicit configured paths.
|
|
171
|
+
│ ├── .ssh/... # from ~/.ssh
|
|
172
|
+
│ └── Documents/notes/... # from ~/Documents/notes
|
|
173
|
+
├── locals/ # Auto-discovered .local directories.
|
|
174
|
+
│ └── Code/pathling/... # from ~/Code/pathling/.local
|
|
175
|
+
└── _versions/ # Versioned overwrites/deletes.
|
|
176
|
+
└── 2026-06-19T03-21-55Z/ # One sub-tree per run that changed something.
|
|
177
|
+
├── files/...
|
|
178
|
+
└── locals/...
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
This layout is a stable contract that manual restore relies on. rangler only
|
|
182
|
+
ever writes under `<remote_base>/<hostname>/`, so other machines' trees are never
|
|
183
|
+
touched.
|
|
184
|
+
|
|
185
|
+
## Restore (manual)
|
|
186
|
+
|
|
187
|
+
Restore is performed manually with rclone against the layout above. For example:
|
|
188
|
+
|
|
189
|
+
```console
|
|
190
|
+
rclone copy backup:rangler/mymac/files/.ssh ~/.ssh
|
|
191
|
+
rclone copy backup:rangler/mymac/locals/Code/pathling ~/Code/pathling/.local
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Earlier versions of a file are found under
|
|
195
|
+
`backup:rangler/mymac/_versions/<timestamp>/...`.
|
|
196
|
+
|
|
197
|
+
## Troubleshooting
|
|
198
|
+
|
|
199
|
+
- **"rclone is not installed or not on your PATH"** - install rclone
|
|
200
|
+
(`brew install rclone`) and confirm `rclone version` works in your shell.
|
|
201
|
+
- **"the remote ... is not reachable"** - the name before the `:` in
|
|
202
|
+
`remote_base` must match a remote from `rclone listremotes`. Create or rename
|
|
203
|
+
it with `rclone config`.
|
|
204
|
+
- **A configured path is reported as skipped** - the path does not exist on this
|
|
205
|
+
machine. This is expected when paths differ across machines; it does not fail
|
|
206
|
+
the run.
|
|
207
|
+
- **A target is reported as failed** - check the per-run log under
|
|
208
|
+
`~/Library/Logs/rangler/` for the rclone error (for example a permission
|
|
209
|
+
problem). The run still backs up every other target and exits non-zero.
|
|
210
|
+
- **"skipped: already running"** - another rangler run holds the lock at
|
|
211
|
+
`~/.local/state/rangler/rangler.lock`. Wait for it to finish; the lock is
|
|
212
|
+
released automatically even if that process is killed.
|
|
213
|
+
- **Scheduled runs are not happening** - confirm the agent is loaded with
|
|
214
|
+
`launchctl print gui/$(id -u)/au.id.grimes.john.rangler` and inspect
|
|
215
|
+
`~/Library/Logs/rangler/launchd.err.log`.
|
|
216
|
+
|
|
217
|
+
## Licence
|
|
218
|
+
|
|
219
|
+
rangler is licensed under the [Apache License, Version 2.0](LICENSE). See the
|
|
220
|
+
[NOTICE](NOTICE) file for attribution.
|
|
221
|
+
|
|
222
|
+
Copyright © 2026 John Grimes.
|