rsync-time-machine 1.0.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.
@@ -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.
@@ -0,0 +1,195 @@
1
+ Metadata-Version: 2.1
2
+ Name: rsync-time-machine
3
+ Version: 1.0.0
4
+ Summary: rsync-time-machine.py is a wrapper around rsync to make it easier to create and maintain Time Machine style backups.
5
+ Author-email: Bas Nijholt <bas@nijho.lt>
6
+ Project-URL: Homepage, https://github.com/basnijholt/rsync-time-machine.py
7
+ Requires-Python: >=3.7
8
+ Description-Content-Type: text/markdown
9
+ Provides-Extra: test
10
+ Provides-Extra: docs
11
+ License-File: LICENSE
12
+
13
+ # Rsync Time Machine πŸ•°οΈπŸ’Ύ
14
+
15
+ Introducing `rsync-time-machine.py` - a Python port of the [`rsync-time-backup`](https://github.com/laurent22/rsync-time-backup) script, offering Time Machine-style backups using rsync. It creates incremental backups of files and directories to the destination of your choice. The backups are structured in a way that makes it easy to recover any file at any point in time. πŸš€
16
+
17
+ It works on Linux, macOS, and Windows (via WSL or Cygwin). The main advantage over Time Machine is flexibility, as it can backup from/to any filesystem and works on any platform. You can also backup to a Truecrypt drive without any problem. πŸ˜ƒ
18
+
19
+ `rsync-time-machine.py` is fully tested, has no external dependencies (only Python β‰₯3.7 🐍), is fully compatible with [`rsync-time-backup`](https://github.com/laurent22/rsync-time-backup), offers pretty terminal output, and is fully typed! πŸŽ‰
20
+
21
+ <details><summary><b><u>[ToC]</u></b> πŸ“š</summary>
22
+
23
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
24
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
25
+
26
+ - [:star2: Features](#star2-features)
27
+ - [:books: Usage](#books-usage)
28
+ - [:hammer_and_wrench: Installation](#hammer_and_wrench-installation)
29
+ - [:bulb: Examples](#bulb-examples)
30
+ - [:calendar: Backup Expiration Logic](#calendar-backup-expiration-logic)
31
+ - [:page_facing_up: Exclusion File](#page_facing_up-exclusion-file)
32
+ - [:lock: Built-in Lock](#lock-built-in-lock)
33
+ - [:gear: Rsync Options](#gear-rsync-options)
34
+ - [:no_entry_sign: No Automatic Backup Expiration](#no_entry_sign-no-automatic-backup-expiration)
35
+ - [:arrows_counterclockwise: How to Restore](#arrows_counterclockwise-how-to-restore)
36
+ - [:heart: Support and Contributions](#heart-support-and-contributions)
37
+
38
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
39
+
40
+ </details>
41
+
42
+ ## :star2: Features
43
+
44
+ * πŸ“ Each backup is in its own folder named after the current timestamp.
45
+ * πŸ”’ Backup to/from remote destinations over SSH.
46
+ * πŸ”— Files that haven't changed from one backup to the next are hard-linked to the previous backup, saving space.
47
+ * ⚠️ Safety check - the backup will only happen if the destination has explicitly been marked as a backup destination.
48
+ * πŸ”„ Resume feature - if a backup has failed or was interrupted, the tool will resume from there on the next backup.
49
+ * 🚫 Exclude file - support for pattern-based exclusion via the `--exclude-from` rsync parameter.
50
+ * 🧹 Automatically purge old backups based on a configurable expiration strategy.
51
+ * πŸ”— "latest" symlink that points to the latest successful backup.
52
+
53
+ ## :books: Usage
54
+
55
+ To use `rsync-time-machine.py`, you'll need to provide source and destination paths, along with any desired options:
56
+
57
+ ```bash
58
+ rsync-time-machine --help
59
+ ```
60
+ Shows the help message:
61
+
62
+ <!-- CODE:BASH:START -->
63
+ <!-- echo '```bash' -->
64
+ <!-- rsync-time-machine --help -->
65
+ <!-- echo '```' -->
66
+ <!-- CODE:END -->
67
+
68
+ <!-- OUTPUT:START -->
69
+ <!-- ⚠️ This content is auto-generated by `markdown-code-runner`. -->
70
+ ```bash
71
+ usage: rsync-time-machine [-h] [-p PORT] [-i ID_RSA] [--rsync-get-flags]
72
+ [--rsync-set-flags RSYNC_SET_FLAGS]
73
+ [--rsync-append-flags RSYNC_APPEND_FLAGS]
74
+ [--log-dir LOG_DIR] [--strategy STRATEGY]
75
+ [--no-auto-expire] [--allow-host-only] [-v]
76
+ src_folder dest_folder [exclusion_file]
77
+
78
+ A script for creating and managing time-stamped backups using rsync.
79
+
80
+ positional arguments:
81
+ src_folder Source folder for backup. Format: [USER@HOST:]SOURCE
82
+ dest_folder Destination folder for backup. Format:
83
+ [USER@HOST:]DESTINATION
84
+ exclusion_file Path to the file containing exclude patterns.
85
+
86
+ options:
87
+ -h, --help show this help message and exit
88
+ -p PORT, --port PORT SSH port.
89
+ -i ID_RSA, --id_rsa ID_RSA
90
+ Specify the private ssh key to use.
91
+ --rsync-get-flags Display the default rsync flags that are used for
92
+ backup. If using remote drive over SSH, --compress
93
+ will be added.
94
+ --rsync-set-flags RSYNC_SET_FLAGS
95
+ Set the rsync flags that are going to be used for
96
+ backup.
97
+ --rsync-append-flags RSYNC_APPEND_FLAGS
98
+ Append the rsync flags that are going to be used for
99
+ backup.
100
+ --log-dir LOG_DIR Set the log file directory. If this flag is set,
101
+ generated files will not be managed by the script - in
102
+ particular they will not be automatically deleted.
103
+ Default: $HOME/.rsync-time-backup
104
+ --strategy STRATEGY Set the expiration strategy. Default: "1:1 30:7
105
+ 365:30" means after one day, keep one backup per day.
106
+ After 30 days, keep one backup every 7 days. After 365
107
+ days keep one backup every 30 days.
108
+ --no-auto-expire Disable automatically deleting backups when out of
109
+ space. Instead, an error is logged, and the backup is
110
+ aborted.
111
+ --allow-host-only By default, the script expects a 'USER@HOST' pattern
112
+ for specifying SSH connections. When this flag is
113
+ used, it allows for the 'HOST' pattern without a
114
+ specified user. This is useful if you want to use
115
+ configurations from the `.ssh/config` file or rely on
116
+ the current username. Note: this option will not
117
+ enforce SSH usage, it only broadens the accepted input
118
+ formats.
119
+ -v, --verbose Enable verbose output.
120
+ ```
121
+
122
+ <!-- OUTPUT:END -->
123
+
124
+ Please refer to the original [`rsync-time-backup`](https://github.com/laurent22/rsync-time-backup) README for a list of options, as they have been preserved in the Python port.
125
+
126
+ ## :hammer_and_wrench: Installation
127
+
128
+ To install `rsync-time-machine.py`, simply clone the repository:
129
+
130
+ ```bash
131
+ pip install rsync-time-machine
132
+ ```
133
+
134
+ and use it like `rsync-time-machine --help`
135
+
136
+ Or just copy the script to your computer:
137
+
138
+ ```bash
139
+ wget https://raw.githubusercontent.com/basnijholt/rsync-time-machine.py/main/rsync_time_machine.py
140
+ ```
141
+ and use it like `./rsync_time_machine.py --help`
142
+
143
+ ## :bulb: Examples
144
+
145
+ * Backup the home folder to backup_drive:
146
+
147
+ ```
148
+ ./rsync_time_machine.py /home /mnt/backup_drive
149
+ ```
150
+
151
+ * Backup with exclusion list:
152
+
153
+ ```
154
+ ./rsync_time_machine.py /home /mnt/backup_drive excluded_patterns.txt
155
+ ```
156
+
157
+ For more examples and detailed usage instructions, please refer to the original [`rsync-time-backup`](https://github.com/laurent22/rsync-time-backup) README.
158
+
159
+ ## :calendar: Backup Expiration Logic
160
+
161
+ Backup sets are automatically deleted following a simple expiration strategy defined with the `--strategy` flag. The default strategy is `1:1 30:7 365:30`. Please see the original README for a detailed explanation.
162
+
163
+ ## :page_facing_up: Exclusion File
164
+
165
+ An optional exclude file can be provided as a third parameter, compatible with the `--exclude-from` parameter of rsync.
166
+
167
+ ## :lock: Built-in Lock
168
+
169
+ The script is designed so that only one backup operation can be active for a given directory, avoiding conflicts.
170
+
171
+ ## :gear: Rsync Options
172
+
173
+ To display, add, or remove rsync options, use the `--rsync-get-flags`, `--rsync-append-flags`, or `--rsync-set-flags` options.
174
+
175
+ ## :no_entry_sign: No Automatic Backup Expiration
176
+
177
+ Use the `--no-auto-expire` flag to disable the default behavior of purging old backups when out of space.
178
+
179
+ ## :arrows_counterclockwise: How to Restore
180
+
181
+ Restoring files from the backup is simple, as the script creates a backup in a regular directory. You can easily copy the files back to the original directory using a command like:
182
+
183
+ ```
184
+ rsync -aP /path/to/last/backup/ /path/to/restore/to/
185
+ ```
186
+
187
+ Consider using the `--dry-run` option to check what exactly is going to be copied. If you want to delete files that exist in the destination but not in the backup, use the `--delete` option. Be extra cautious when using this option to avoid data loss.
188
+
189
+ You can also restore files using any file explorer, including Finder on macOS or the command line.
190
+
191
+ ## :heart: Support and Contributions
192
+
193
+ We appreciate your feedback and contributions! If you encounter any issues or have suggestions for improvements, please file an issue on the GitHub repository. We also welcome pull requests for bug fixes or new features.
194
+
195
+ Happy backing up! πŸ’ΎπŸ•°οΈπŸŽ‰
@@ -0,0 +1,183 @@
1
+ # Rsync Time Machine πŸ•°οΈπŸ’Ύ
2
+
3
+ Introducing `rsync-time-machine.py` - a Python port of the [`rsync-time-backup`](https://github.com/laurent22/rsync-time-backup) script, offering Time Machine-style backups using rsync. It creates incremental backups of files and directories to the destination of your choice. The backups are structured in a way that makes it easy to recover any file at any point in time. πŸš€
4
+
5
+ It works on Linux, macOS, and Windows (via WSL or Cygwin). The main advantage over Time Machine is flexibility, as it can backup from/to any filesystem and works on any platform. You can also backup to a Truecrypt drive without any problem. πŸ˜ƒ
6
+
7
+ `rsync-time-machine.py` is fully tested, has no external dependencies (only Python β‰₯3.7 🐍), is fully compatible with [`rsync-time-backup`](https://github.com/laurent22/rsync-time-backup), offers pretty terminal output, and is fully typed! πŸŽ‰
8
+
9
+ <details><summary><b><u>[ToC]</u></b> πŸ“š</summary>
10
+
11
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
12
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
13
+
14
+ - [:star2: Features](#star2-features)
15
+ - [:books: Usage](#books-usage)
16
+ - [:hammer_and_wrench: Installation](#hammer_and_wrench-installation)
17
+ - [:bulb: Examples](#bulb-examples)
18
+ - [:calendar: Backup Expiration Logic](#calendar-backup-expiration-logic)
19
+ - [:page_facing_up: Exclusion File](#page_facing_up-exclusion-file)
20
+ - [:lock: Built-in Lock](#lock-built-in-lock)
21
+ - [:gear: Rsync Options](#gear-rsync-options)
22
+ - [:no_entry_sign: No Automatic Backup Expiration](#no_entry_sign-no-automatic-backup-expiration)
23
+ - [:arrows_counterclockwise: How to Restore](#arrows_counterclockwise-how-to-restore)
24
+ - [:heart: Support and Contributions](#heart-support-and-contributions)
25
+
26
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
27
+
28
+ </details>
29
+
30
+ ## :star2: Features
31
+
32
+ * πŸ“ Each backup is in its own folder named after the current timestamp.
33
+ * πŸ”’ Backup to/from remote destinations over SSH.
34
+ * πŸ”— Files that haven't changed from one backup to the next are hard-linked to the previous backup, saving space.
35
+ * ⚠️ Safety check - the backup will only happen if the destination has explicitly been marked as a backup destination.
36
+ * πŸ”„ Resume feature - if a backup has failed or was interrupted, the tool will resume from there on the next backup.
37
+ * 🚫 Exclude file - support for pattern-based exclusion via the `--exclude-from` rsync parameter.
38
+ * 🧹 Automatically purge old backups based on a configurable expiration strategy.
39
+ * πŸ”— "latest" symlink that points to the latest successful backup.
40
+
41
+ ## :books: Usage
42
+
43
+ To use `rsync-time-machine.py`, you'll need to provide source and destination paths, along with any desired options:
44
+
45
+ ```bash
46
+ rsync-time-machine --help
47
+ ```
48
+ Shows the help message:
49
+
50
+ <!-- CODE:BASH:START -->
51
+ <!-- echo '```bash' -->
52
+ <!-- rsync-time-machine --help -->
53
+ <!-- echo '```' -->
54
+ <!-- CODE:END -->
55
+
56
+ <!-- OUTPUT:START -->
57
+ <!-- ⚠️ This content is auto-generated by `markdown-code-runner`. -->
58
+ ```bash
59
+ usage: rsync-time-machine [-h] [-p PORT] [-i ID_RSA] [--rsync-get-flags]
60
+ [--rsync-set-flags RSYNC_SET_FLAGS]
61
+ [--rsync-append-flags RSYNC_APPEND_FLAGS]
62
+ [--log-dir LOG_DIR] [--strategy STRATEGY]
63
+ [--no-auto-expire] [--allow-host-only] [-v]
64
+ src_folder dest_folder [exclusion_file]
65
+
66
+ A script for creating and managing time-stamped backups using rsync.
67
+
68
+ positional arguments:
69
+ src_folder Source folder for backup. Format: [USER@HOST:]SOURCE
70
+ dest_folder Destination folder for backup. Format:
71
+ [USER@HOST:]DESTINATION
72
+ exclusion_file Path to the file containing exclude patterns.
73
+
74
+ options:
75
+ -h, --help show this help message and exit
76
+ -p PORT, --port PORT SSH port.
77
+ -i ID_RSA, --id_rsa ID_RSA
78
+ Specify the private ssh key to use.
79
+ --rsync-get-flags Display the default rsync flags that are used for
80
+ backup. If using remote drive over SSH, --compress
81
+ will be added.
82
+ --rsync-set-flags RSYNC_SET_FLAGS
83
+ Set the rsync flags that are going to be used for
84
+ backup.
85
+ --rsync-append-flags RSYNC_APPEND_FLAGS
86
+ Append the rsync flags that are going to be used for
87
+ backup.
88
+ --log-dir LOG_DIR Set the log file directory. If this flag is set,
89
+ generated files will not be managed by the script - in
90
+ particular they will not be automatically deleted.
91
+ Default: $HOME/.rsync-time-backup
92
+ --strategy STRATEGY Set the expiration strategy. Default: "1:1 30:7
93
+ 365:30" means after one day, keep one backup per day.
94
+ After 30 days, keep one backup every 7 days. After 365
95
+ days keep one backup every 30 days.
96
+ --no-auto-expire Disable automatically deleting backups when out of
97
+ space. Instead, an error is logged, and the backup is
98
+ aborted.
99
+ --allow-host-only By default, the script expects a 'USER@HOST' pattern
100
+ for specifying SSH connections. When this flag is
101
+ used, it allows for the 'HOST' pattern without a
102
+ specified user. This is useful if you want to use
103
+ configurations from the `.ssh/config` file or rely on
104
+ the current username. Note: this option will not
105
+ enforce SSH usage, it only broadens the accepted input
106
+ formats.
107
+ -v, --verbose Enable verbose output.
108
+ ```
109
+
110
+ <!-- OUTPUT:END -->
111
+
112
+ Please refer to the original [`rsync-time-backup`](https://github.com/laurent22/rsync-time-backup) README for a list of options, as they have been preserved in the Python port.
113
+
114
+ ## :hammer_and_wrench: Installation
115
+
116
+ To install `rsync-time-machine.py`, simply clone the repository:
117
+
118
+ ```bash
119
+ pip install rsync-time-machine
120
+ ```
121
+
122
+ and use it like `rsync-time-machine --help`
123
+
124
+ Or just copy the script to your computer:
125
+
126
+ ```bash
127
+ wget https://raw.githubusercontent.com/basnijholt/rsync-time-machine.py/main/rsync_time_machine.py
128
+ ```
129
+ and use it like `./rsync_time_machine.py --help`
130
+
131
+ ## :bulb: Examples
132
+
133
+ * Backup the home folder to backup_drive:
134
+
135
+ ```
136
+ ./rsync_time_machine.py /home /mnt/backup_drive
137
+ ```
138
+
139
+ * Backup with exclusion list:
140
+
141
+ ```
142
+ ./rsync_time_machine.py /home /mnt/backup_drive excluded_patterns.txt
143
+ ```
144
+
145
+ For more examples and detailed usage instructions, please refer to the original [`rsync-time-backup`](https://github.com/laurent22/rsync-time-backup) README.
146
+
147
+ ## :calendar: Backup Expiration Logic
148
+
149
+ Backup sets are automatically deleted following a simple expiration strategy defined with the `--strategy` flag. The default strategy is `1:1 30:7 365:30`. Please see the original README for a detailed explanation.
150
+
151
+ ## :page_facing_up: Exclusion File
152
+
153
+ An optional exclude file can be provided as a third parameter, compatible with the `--exclude-from` parameter of rsync.
154
+
155
+ ## :lock: Built-in Lock
156
+
157
+ The script is designed so that only one backup operation can be active for a given directory, avoiding conflicts.
158
+
159
+ ## :gear: Rsync Options
160
+
161
+ To display, add, or remove rsync options, use the `--rsync-get-flags`, `--rsync-append-flags`, or `--rsync-set-flags` options.
162
+
163
+ ## :no_entry_sign: No Automatic Backup Expiration
164
+
165
+ Use the `--no-auto-expire` flag to disable the default behavior of purging old backups when out of space.
166
+
167
+ ## :arrows_counterclockwise: How to Restore
168
+
169
+ Restoring files from the backup is simple, as the script creates a backup in a regular directory. You can easily copy the files back to the original directory using a command like:
170
+
171
+ ```
172
+ rsync -aP /path/to/last/backup/ /path/to/restore/to/
173
+ ```
174
+
175
+ Consider using the `--dry-run` option to check what exactly is going to be copied. If you want to delete files that exist in the destination but not in the backup, use the `--delete` option. Be extra cautious when using this option to avoid data loss.
176
+
177
+ You can also restore files using any file explorer, including Finder on macOS or the command line.
178
+
179
+ ## :heart: Support and Contributions
180
+
181
+ We appreciate your feedback and contributions! If you encounter any issues or have suggestions for improvements, please file an issue on the GitHub repository. We also welcome pull requests for bug fixes or new features.
182
+
183
+ Happy backing up! πŸ’ΎπŸ•°οΈπŸŽ‰
@@ -0,0 +1,83 @@
1
+ [build-system]
2
+ requires = ["setuptools>=42", "wheel", "versioningit"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "rsync-time-machine"
7
+ description = "rsync-time-machine.py is a wrapper around rsync to make it easier to create and maintain Time Machine style backups."
8
+ dynamic = ["version"]
9
+ authors = [{ name = "Bas Nijholt", email = "bas@nijho.lt" }]
10
+ dependencies = []
11
+ requires-python = ">=3.7"
12
+
13
+ [project.readme]
14
+ file = "README.md"
15
+ content-type = "text/markdown"
16
+
17
+ [project.urls]
18
+ Homepage = "https://github.com/basnijholt/rsync-time-machine.py"
19
+
20
+ [project.optional-dependencies]
21
+ test = ["pytest", "pre-commit", "coverage", "pytest-cov"]
22
+ docs = []
23
+
24
+ [project.scripts]
25
+ rsync-time-machine = "rsync_time_machine:main"
26
+
27
+ [tool.setuptools]
28
+ py-modules = ["rsync_time_machine"]
29
+
30
+ [tool.pytest.ini_options]
31
+ addopts = """
32
+ --cov=rsync_time_machine
33
+ --cov-report term
34
+ --cov-report html
35
+ --cov-fail-under=70
36
+ """
37
+
38
+ [tool.coverage.report]
39
+ exclude_lines = [
40
+ "pragma: no cover",
41
+ "raise NotImplementedError",
42
+ "if TYPE_CHECKING:",
43
+ "if __name__ == .__main__.:",
44
+ ]
45
+
46
+ [tool.black]
47
+ line_length = 88
48
+
49
+ [tool.ruff]
50
+ line-length = 150
51
+ target-version = "py37"
52
+ select = ["ALL"]
53
+ ignore = [
54
+ "T20", # flake8-print
55
+ "ANN101", # Missing type annotation for {name} in method
56
+ "S101", # Use of assert detected
57
+ "PD901", # df is a bad variable name. Be kinder to your future self.
58
+ "ANN401", # Dynamically typed expressions (typing.Any) are disallowed in {name}
59
+ "D402", # First line should not be the function's signature
60
+ "PLW0603", # Using the global statement to update `X` is discouraged
61
+ "D401", # First line of docstring should be in imperative mood
62
+ "SLF001", # Private member accessed
63
+ "PTH", # Use pathlib.Path
64
+ "DTZ005", # The use of `datetime.datetime.now()` without `tz` argument is not allowed
65
+ "PLR0913", # Too many arguments to function call
66
+ ]
67
+
68
+ [tool.ruff.per-file-ignores]
69
+ "tests/*" = ["SLF001"]
70
+ ".github/*" = ["INP001"]
71
+
72
+ [tool.ruff.mccabe]
73
+ max-complexity = 18
74
+
75
+ [tool.mypy]
76
+ python_version = "3.7"
77
+
78
+ [tool.versioningit]
79
+
80
+ [tool.versioningit.vcs]
81
+ method = "git"
82
+ match = ["v*"]
83
+ default-tag = "0.0.0"