irsync 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.
- irsync-0.1.0/.github/dependabot.yml +6 -0
- irsync-0.1.0/.github/workflows/release.yml +35 -0
- irsync-0.1.0/.github/workflows/test.yml +38 -0
- irsync-0.1.0/.gitignore +37 -0
- irsync-0.1.0/.pre-commit-config.yaml +31 -0
- irsync-0.1.0/LICENSE +201 -0
- irsync-0.1.0/PKG-INFO +267 -0
- irsync-0.1.0/PROGRESS.md +46 -0
- irsync-0.1.0/README.md +237 -0
- irsync-0.1.0/RELEASING.md +64 -0
- irsync-0.1.0/docs/design/irsync-architecture.md +731 -0
- irsync-0.1.0/docs/hygiene-notes.md +533 -0
- irsync-0.1.0/docs/superpowers/plans/2026-07-31-mount-safety.md +1380 -0
- irsync-0.1.0/docs/superpowers/plans/2026-07-31-mount-safety.md.tasks.json +84 -0
- irsync-0.1.0/docs/superpowers/specs/2026-07-31-mount-safety-design.md +286 -0
- irsync-0.1.0/pixi.lock +3632 -0
- irsync-0.1.0/pixi.toml +56 -0
- irsync-0.1.0/pyproject.toml +106 -0
- irsync-0.1.0/src/irsync/__init__.py +3 -0
- irsync-0.1.0/src/irsync/__main__.py +12 -0
- irsync-0.1.0/src/irsync/backup.py +951 -0
- irsync-0.1.0/src/irsync/cli.py +275 -0
- irsync-0.1.0/src/irsync/diff.py +434 -0
- irsync-0.1.0/src/irsync/options.py +400 -0
- irsync-0.1.0/src/irsync/paths.py +61 -0
- irsync-0.1.0/src/irsync/preflight.py +254 -0
- irsync-0.1.0/src/irsync/py.typed +0 -0
- irsync-0.1.0/src/irsync/replay.py +168 -0
- irsync-0.1.0/src/irsync/rsync_runner.py +224 -0
- irsync-0.1.0/src/irsync/snapshot.py +346 -0
- irsync-0.1.0/src/irsync/statx.py +139 -0
- irsync-0.1.0/tests/__init__.py +0 -0
- irsync-0.1.0/tests/conftest.py +193 -0
- irsync-0.1.0/tests/test_backup.py +2064 -0
- irsync-0.1.0/tests/test_cli.py +545 -0
- irsync-0.1.0/tests/test_diff.py +711 -0
- irsync-0.1.0/tests/test_integration.py +787 -0
- irsync-0.1.0/tests/test_main.py +71 -0
- irsync-0.1.0/tests/test_options.py +411 -0
- irsync-0.1.0/tests/test_paths.py +75 -0
- irsync-0.1.0/tests/test_preflight.py +258 -0
- irsync-0.1.0/tests/test_replay.py +197 -0
- irsync-0.1.0/tests/test_rsync_runner.py +355 -0
- irsync-0.1.0/tests/test_snapshot.py +530 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
name: release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags: ["v*"]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
build:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v7
|
|
12
|
+
- uses: actions/setup-python@v6
|
|
13
|
+
with:
|
|
14
|
+
python-version: "3.14"
|
|
15
|
+
- run: python -m pip install --upgrade pip build twine
|
|
16
|
+
- run: python -m build
|
|
17
|
+
- run: twine check dist/*
|
|
18
|
+
- uses: actions/upload-artifact@v7
|
|
19
|
+
with:
|
|
20
|
+
name: dist
|
|
21
|
+
path: dist/
|
|
22
|
+
|
|
23
|
+
publish:
|
|
24
|
+
needs: build
|
|
25
|
+
runs-on: ubuntu-latest
|
|
26
|
+
environment: pypi
|
|
27
|
+
permissions:
|
|
28
|
+
id-token: write # OIDC token for PyPI Trusted Publishing
|
|
29
|
+
steps:
|
|
30
|
+
- uses: actions/download-artifact@v8
|
|
31
|
+
with:
|
|
32
|
+
name: dist
|
|
33
|
+
path: dist/
|
|
34
|
+
# Pinned by commit SHA (v1.14.0) per supply-chain guidance; Dependabot bumps it.
|
|
35
|
+
- uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
name: test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
lint:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v7
|
|
13
|
+
- uses: actions/setup-python@v6
|
|
14
|
+
with:
|
|
15
|
+
python-version: "3.14"
|
|
16
|
+
- run: python -m pip install --upgrade pip
|
|
17
|
+
- run: pip install .[dev]
|
|
18
|
+
- run: ruff check .
|
|
19
|
+
- run: ruff format --check .
|
|
20
|
+
|
|
21
|
+
test:
|
|
22
|
+
runs-on: ${{ matrix.os }}
|
|
23
|
+
strategy:
|
|
24
|
+
fail-fast: false
|
|
25
|
+
matrix:
|
|
26
|
+
os: [ubuntu-latest]
|
|
27
|
+
python-version: ["3.12", "3.13", "3.14"]
|
|
28
|
+
include:
|
|
29
|
+
- os: macos-latest
|
|
30
|
+
python-version: "3.14"
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions/checkout@v7
|
|
33
|
+
- uses: actions/setup-python@v6
|
|
34
|
+
with:
|
|
35
|
+
python-version: ${{ matrix.python-version }}
|
|
36
|
+
- run: python -m pip install --upgrade pip
|
|
37
|
+
- run: pip install .[dev]
|
|
38
|
+
- run: pytest
|
irsync-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.pyc
|
|
3
|
+
*.pyo
|
|
4
|
+
.coverage
|
|
5
|
+
*.egg-info/
|
|
6
|
+
*.egg
|
|
7
|
+
.DS_Store
|
|
8
|
+
dist/
|
|
9
|
+
build/
|
|
10
|
+
htmlcov/
|
|
11
|
+
.venv/
|
|
12
|
+
.env*
|
|
13
|
+
!.env.example
|
|
14
|
+
.pytest_cache/
|
|
15
|
+
.mypy_cache/
|
|
16
|
+
.ruff_cache/
|
|
17
|
+
.pixi/
|
|
18
|
+
|
|
19
|
+
.claude-project-id
|
|
20
|
+
|
|
21
|
+
.sandbox_settings.json
|
|
22
|
+
|
|
23
|
+
# Local dev-process docs — intentionally not published (restored from backup)
|
|
24
|
+
CLAUDE.md
|
|
25
|
+
|
|
26
|
+
# Credential-hygiene notes and anything else too operational to publish.
|
|
27
|
+
# PROGRESS.md is tracked and therefore public; this is where such notes go.
|
|
28
|
+
SECURITY-TODO.local.md
|
|
29
|
+
|
|
30
|
+
# PROGRESS.md was listed here too until 2026-09-04. It is now tracked: it is
|
|
31
|
+
# the file the session-resume protocol tells every session to read first, and
|
|
32
|
+
# leaving it untracked meant a re-cloned workspace lost the whole notebook of
|
|
33
|
+
# decisions, gotchas, and open questions — and made the project's own
|
|
34
|
+
# durability rule ("commit PROGRESS.md after each task") impossible to follow.
|
|
35
|
+
|
|
36
|
+
# Local Claude Code hook config (PreCompact summarize-and-exit); dev-process only.
|
|
37
|
+
.claude/
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
exclude: '^(srsync|inode_compare\.py|make_random_moves\.py|make_random_tree\.py|inode_snapshot_.*\.jsonl|plan\.txt)$'
|
|
2
|
+
|
|
3
|
+
repos:
|
|
4
|
+
- repo: local
|
|
5
|
+
hooks: # On macOS, pixi-installed tools (pytest, ruff, mypy) can fail due to shebang path resolution issues. Using python -m <tool> bypasses this reliably.
|
|
6
|
+
- id: ruff
|
|
7
|
+
name: ruff
|
|
8
|
+
entry: pixi run python -m ruff check --fix
|
|
9
|
+
language: system
|
|
10
|
+
types: [python]
|
|
11
|
+
- id: ruff-format
|
|
12
|
+
name: ruff-format
|
|
13
|
+
entry: pixi run python -m ruff format
|
|
14
|
+
language: system
|
|
15
|
+
types: [python]
|
|
16
|
+
- id: mypy
|
|
17
|
+
name: mypy
|
|
18
|
+
entry: pixi run python -m mypy .
|
|
19
|
+
language: system
|
|
20
|
+
types: [python]
|
|
21
|
+
pass_filenames: false
|
|
22
|
+
|
|
23
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
24
|
+
rev: v5.0.0
|
|
25
|
+
hooks:
|
|
26
|
+
- id: trailing-whitespace
|
|
27
|
+
- id: end-of-file-fixer
|
|
28
|
+
- id: check-yaml
|
|
29
|
+
- id: check-toml
|
|
30
|
+
- id: check-added-large-files
|
|
31
|
+
- id: check-merge-conflict
|
irsync-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 2026 Emmy Killett
|
|
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.
|
irsync-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: irsync
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Rename-aware rsync wrapper that uses inode snapshots to skip retransfer of moved files.
|
|
5
|
+
Project-URL: Homepage, https://github.com/killett/irsync
|
|
6
|
+
Project-URL: Repository, https://github.com/killett/irsync
|
|
7
|
+
Project-URL: Issues, https://github.com/killett/irsync/issues
|
|
8
|
+
Author-email: Emmy Killett <57272627+killett@users.noreply.github.com>
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: backup,inode,rename,rsync,snapshot
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: System Administrators
|
|
15
|
+
Classifier: Operating System :: POSIX
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Topic :: System :: Archiving :: Backup
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
Requires-Python: >=3.12
|
|
23
|
+
Requires-Dist: drivecfg<1,>=0.1
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: mypy; extra == 'dev'
|
|
26
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest-cov; extra == 'dev'
|
|
28
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# irsync
|
|
32
|
+
|
|
33
|
+
Rename-aware Python wrapper around `rsync`. When files are moved or renamed on
|
|
34
|
+
the source drive, the original `rsync` deletes the old path on the backup drive
|
|
35
|
+
and re-transfers the (often huge) file from scratch. `irsync` avoids that by
|
|
36
|
+
keeping an inode snapshot at the root of the source tree, comparing it against
|
|
37
|
+
a fresh snapshot on each run, and replaying just the moves/renames atomically
|
|
38
|
+
on the backup tree before invoking `rsync` for the actual content delta. When
|
|
39
|
+
no source changes are detected at all, the backup drive is never accessed.
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pip install irsync
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`irsync` calls the system `rsync` binary, so `rsync` must be installed and on
|
|
48
|
+
your `PATH`. Its only Python dependency is
|
|
49
|
+
[`drivecfg`](https://github.com/killett/drivecfg), which supplies the optional
|
|
50
|
+
drive shorthands described under [Configuration](#configuration).
|
|
51
|
+
|
|
52
|
+
## Quick usage
|
|
53
|
+
|
|
54
|
+
Installation puts an `irsync` command on your `PATH` (equivalently,
|
|
55
|
+
`python -m irsync`):
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# First backup of a drive: snapshots both sides, then runs rsync.
|
|
59
|
+
irsync /mnt/data /mnt/data_backup --yes
|
|
60
|
+
|
|
61
|
+
# Subsequent run with files renamed on /mnt/data:
|
|
62
|
+
# the inode diff is computed, the renames are replayed on /mnt/data_backup
|
|
63
|
+
# using os.rename, and rsync handles only the actual content changes.
|
|
64
|
+
irsync /mnt/data /mnt/data_backup --yes
|
|
65
|
+
|
|
66
|
+
# Subsequent run with no source changes: the backup drive is never touched.
|
|
67
|
+
irsync /mnt/data /mnt/data_backup --yes
|
|
68
|
+
|
|
69
|
+
# Force a full rsync run even when the snapshot says nothing changed.
|
|
70
|
+
irsync /mnt/data /mnt/data_backup --yes --force
|
|
71
|
+
|
|
72
|
+
# Take a baseline snapshot without backing up (e.g. before a big reorg).
|
|
73
|
+
irsync /mnt/data --snapshot-only
|
|
74
|
+
|
|
75
|
+
# Skip the inode logic entirely and run a plain delete-before rsync.
|
|
76
|
+
irsync /mnt/data /mnt/data_backup --no-snapshot
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Everything above works on plain paths and needs no configuration at all.
|
|
80
|
+
|
|
81
|
+
## Configuration
|
|
82
|
+
|
|
83
|
+
irsync can also take shorthands — a drive id, a named endpoint such as `~` or
|
|
84
|
+
`mypython`, or `ALL` for a whole-machine run — instead of a source and
|
|
85
|
+
destination. Those names mean nothing on their own, so they are read from a
|
|
86
|
+
[`drivecfg`](https://github.com/killett/drivecfg) config file. irsync loads it
|
|
87
|
+
lazily, and how lazily depends on the invocation:
|
|
88
|
+
|
|
89
|
+
- **`irsync SOURCE DEST`**, two plain paths, never looks for one. This is the
|
|
90
|
+
only shape that skips discovery entirely.
|
|
91
|
+
- **A shorthand** (a drive id, an endpoint name, or `ALL`) always looks for
|
|
92
|
+
one, whether or not a destination was also given, and refuses with exit
|
|
93
|
+
code 2 if none is found, naming every location it tried.
|
|
94
|
+
- **A single path with no destination** also always looks for one, even
|
|
95
|
+
though it might turn out to be an ordinary directory rather than a
|
|
96
|
+
configured name — irsync has to check before it can tell the difference —
|
|
97
|
+
and refuses the same way if none is found.
|
|
98
|
+
- **`--snapshot-only`** is the one case that looks without requiring: it
|
|
99
|
+
consults a config if one exists (so a configured name still resolves), but
|
|
100
|
+
a missing file is not an error there — it falls back to treating the
|
|
101
|
+
argument as a literal path.
|
|
102
|
+
|
|
103
|
+
Naming a config explicitly, with `--config` or `$DRIVECFG_CONFIG`, always
|
|
104
|
+
triggers a load attempt and always refuses if that specific file is missing,
|
|
105
|
+
regardless of which of the above shapes it's attached to.
|
|
106
|
+
|
|
107
|
+
The file is discovered from `--config PATH`, then `$DRIVECFG_CONFIG`, then
|
|
108
|
+
`$XDG_CONFIG_HOME/drivecfg/drives.toml` (usually
|
|
109
|
+
`~/.config/drivecfg/drives.toml`). A short example, with invented drive ids:
|
|
110
|
+
|
|
111
|
+
```toml
|
|
112
|
+
schema_version = 1
|
|
113
|
+
base_dir = "/media/alice"
|
|
114
|
+
|
|
115
|
+
drives = [
|
|
116
|
+
{ id = "A", enclosure = "desk-dock" },
|
|
117
|
+
{ id = "B", dir = "photos", backup_dir = "photos_backup" },
|
|
118
|
+
{ id = "C", backup = false },
|
|
119
|
+
]
|
|
120
|
+
|
|
121
|
+
# What `irsync ALL` runs, in order. "*drives" expands to every drive
|
|
122
|
+
# with backup = true, in file order.
|
|
123
|
+
backup_order = ["mypython", "*drives", "~"]
|
|
124
|
+
|
|
125
|
+
[endpoints."~"]
|
|
126
|
+
source = { path = "~" }
|
|
127
|
+
dest = { drive = "A", path = "home_backup" }
|
|
128
|
+
|
|
129
|
+
[endpoints.mypython]
|
|
130
|
+
source = { drive = "B", path = "projects/python" }
|
|
131
|
+
dest = { drive = "A", path = "python_backup" }
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
With that file in place:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
irsync A # /media/alice/A -> /media/alice/A_backup
|
|
138
|
+
irsync B # /media/alice/photos -> /media/alice/photos_backup
|
|
139
|
+
irsync mypython # the configured source/destination pair
|
|
140
|
+
irsync ALL --yes # every entry of backup_order, in order
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
A drive id that the config does not define is refused with exit code 2 and a
|
|
144
|
+
message naming the drives that *are* configured — irsync never guesses a path
|
|
145
|
+
for an unknown name. `base_dir` is used only as the mount-gate root (see
|
|
146
|
+
[Safety](#safety)); when no config is loaded it defaults to
|
|
147
|
+
`/media/<your-username>`, which can refuse a run but can never redirect one.
|
|
148
|
+
|
|
149
|
+
## Safety
|
|
150
|
+
|
|
151
|
+
irsync fails closed: when it cannot establish that an endpoint is the drive
|
|
152
|
+
you meant, it refuses with exit code 2 instead of proceeding. The motivating
|
|
153
|
+
case is a removable drive that isn't mounted — its mountpoint directory still
|
|
154
|
+
exists and is empty, which every other check reads as a legitimate empty
|
|
155
|
+
tree. Left unchecked, an empty *source* lets `rsync --delete-before` erase
|
|
156
|
+
the destination, and irsync would exit 0 and call it a successful backup.
|
|
157
|
+
|
|
158
|
+
- **The drive is not mounted.** Any endpoint that resolves under the media
|
|
159
|
+
base directory (e.g. `/media/<user>/A`) must sit on a mounted filesystem;
|
|
160
|
+
the base directory itself is exempt, since it is the ordinary directory
|
|
161
|
+
that *contains* mountpoints, not a mountpoint itself. `--require-mount`
|
|
162
|
+
extends this check to endpoints outside the base directory too (the base
|
|
163
|
+
directory stays exempt either way). `--allow-unmounted` proceeds anyway.
|
|
164
|
+
- **A first backup would destroy data.** When there is no usable snapshot
|
|
165
|
+
baseline — none exists yet, or an existing one is rejected because it
|
|
166
|
+
belongs to a different source tree — a *local* destination that already
|
|
167
|
+
holds files other than irsync's own snapshot/lock is refused, because
|
|
168
|
+
`rsync --delete-before` would remove them. A remote destination is never
|
|
169
|
+
scanned, so this guard only applies locally. `--allow-nonempty-dest`
|
|
170
|
+
adopts the destination anyway.
|
|
171
|
+
- **A first backup would come from an empty source.** Also gated on there
|
|
172
|
+
being no usable baseline: a source with no entries besides irsync's own
|
|
173
|
+
reserved files is never a legitimate backup — it is the signature of an
|
|
174
|
+
unmounted or mistyped source — so the run refuses regardless of what the
|
|
175
|
+
destination holds. Firing only when there is no baseline keeps this
|
|
176
|
+
independent of the >50% deletion guard below: a genuine "I deleted
|
|
177
|
+
everything" run, with a baseline in place, is handled by that guard
|
|
178
|
+
instead. `--allow-empty-source` proceeds anyway.
|
|
179
|
+
- **A run would delete more than half of what's recorded.** Independent of
|
|
180
|
+
the above, if the diff says more than 50% of the previously-recorded
|
|
181
|
+
entries are gone, the run refuses — usually a swapped-source or
|
|
182
|
+
stale-snapshot accident. `--allow-massive-delete` overrides it. `--force`
|
|
183
|
+
does *not* — it only means "run rsync even though the snapshot diff found
|
|
184
|
+
no changes."
|
|
185
|
+
- **`--dry-run` changes nothing.** Honored on both the normal (snapshot)
|
|
186
|
+
path and `--no-snapshot`: irsync shows what rsync would do and exits 0
|
|
187
|
+
without touching the destination or persisting a snapshot, on either
|
|
188
|
+
path. Note that the empty-source refusal above is deliberately **not**
|
|
189
|
+
`--dry-run`-exempt (a preview of an empty source is a wall of deletions,
|
|
190
|
+
which conveys less than the refusal message does), so it still fires
|
|
191
|
+
first even under `--dry-run`; the nonempty-destination refusal, by
|
|
192
|
+
contrast, is exempt and merely previews.
|
|
193
|
+
|
|
194
|
+
| Flag | Effect |
|
|
195
|
+
|---|---|
|
|
196
|
+
| `--allow-unmounted` | proceed even if the drive is not mounted |
|
|
197
|
+
| `--allow-nonempty-dest` | adopt a destination that already holds files, on a baseline-less run |
|
|
198
|
+
| `--allow-empty-source` | proceed with a baseline-less run even though the source is empty |
|
|
199
|
+
| `--allow-massive-delete` | proceed when the diff would delete more than half of the recorded entries |
|
|
200
|
+
| `--require-mount` | also apply the mount check to endpoints outside the media base directory |
|
|
201
|
+
| `--force` | run rsync even when the snapshot diff found no changes (nothing else) |
|
|
202
|
+
|
|
203
|
+
Each flag disarms exactly one guard, so a cron line cannot silently lose a
|
|
204
|
+
protection it did not name. If a refusal fires on a drive you expect to be
|
|
205
|
+
attached, check that it is actually mounted before reaching for a flag.
|
|
206
|
+
|
|
207
|
+
An `ALL` run treats an unmounted **source** as a **skip, not an error**: the
|
|
208
|
+
configured list names every drive you might ever attach, so missing ones are
|
|
209
|
+
expected. An unmounted **destination** is different and counts as a real
|
|
210
|
+
**error**: if the source drive is mounted but its backup drive is not, the
|
|
211
|
+
run would back up nothing while still looking like success, which is exactly
|
|
212
|
+
what this guard exists to prevent. Either way the batch continues to the next
|
|
213
|
+
drive rather than stopping. A run with only skips still exits 0, naming both
|
|
214
|
+
the skipped and the successfully backed-up drives in its summary; a run with
|
|
215
|
+
at least one unmounted destination (or any other real error) exits 1. A
|
|
216
|
+
non-zero exit from `ALL` means a backup actually failed (1) or you aborted at
|
|
217
|
+
the prompt (130).
|
|
218
|
+
|
|
219
|
+
## Project structure
|
|
220
|
+
|
|
221
|
+
```
|
|
222
|
+
src/irsync/
|
|
223
|
+
paths.py # is_rsync_remote, ensure_local_dir, with_trailing_slash
|
|
224
|
+
snapshot.py # snapshot_tree, write_snapshot, read_snapshot, SNAPSHOT_FILENAME
|
|
225
|
+
statx.py # ctypes statx(2) wrapper — inode birth time (btime)
|
|
226
|
+
preflight.py # mount / empty-source / nonempty-dest / rsync-present guards
|
|
227
|
+
diff.py # compute_changes, plan_directory_moves (cycle-safe)
|
|
228
|
+
replay.py # apply_moves — atomic os.rename on the dest tree
|
|
229
|
+
rsync_runner.py # build_rsync_command, run_dry_run, run_real_sync
|
|
230
|
+
options.py # Options dataclass, drivecfg-backed resolve_endpoints/resolve_source
|
|
231
|
+
backup.py # the orchestrator: snapshot → diff → replay → rsync → persist
|
|
232
|
+
cli.py # argparse CLI
|
|
233
|
+
__main__.py # `python -m irsync` entry point
|
|
234
|
+
tests/ # pytest unit + end-to-end tests
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Development
|
|
238
|
+
|
|
239
|
+
This project uses [pixi](https://pixi.sh) for the dev environment:
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
pixi run test # pytest
|
|
243
|
+
pixi run lint # ruff check
|
|
244
|
+
pixi run format # ruff format
|
|
245
|
+
pixi run typecheck # mypy --strict
|
|
246
|
+
pixi run pre-commit run --all-files
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### `drivecfg` on PyPI
|
|
250
|
+
|
|
251
|
+
`pyproject.toml` declares `drivecfg>=0.1,<1` as a real runtime dependency.
|
|
252
|
+
`drivecfg` [0.1.0 is published on PyPI](https://pypi.org/project/drivecfg/0.1.0/),
|
|
253
|
+
so this resolves normally: CI's `pip install .[dev]` and the dev environment's
|
|
254
|
+
`pixi install` both install the real package. The formerly-required ordering
|
|
255
|
+
("publish drivecfg before pushing or tagging irsync") is satisfied and no
|
|
256
|
+
longer something a release needs to check.
|
|
257
|
+
|
|
258
|
+
The dev environment used to sidestep the missing package with a temporary
|
|
259
|
+
`PYTHONPATH` shim pointing at a sibling `../drivecfg/src` checkout, wired into
|
|
260
|
+
`pixi.toml` and `pyproject.toml`. That shim has been removed now that
|
|
261
|
+
`drivecfg` installs normally; `pixi.toml`'s `[pypi-exclude-newer]` carries a
|
|
262
|
+
scoped override so the workspace's cooldown doesn't block picking up
|
|
263
|
+
first-party releases the same day they're published.
|
|
264
|
+
|
|
265
|
+
## License
|
|
266
|
+
|
|
267
|
+
Apache-2.0. See [LICENSE](LICENSE).
|