You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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. 🚀
14
17
15
18
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. 😃
16
19
17
20
`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! 🎉
18
21
22
+
<!-- SECTION:intro:END -->
23
+
19
24
<details><summary><b><u>[ToC]</u></b> 📚</summary>
20
25
21
26
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
@@ -33,11 +38,17 @@ It works on Linux, macOS, and Windows (via WSL or Cygwin). The main advantage ov
33
38
-[:arrows_counterclockwise: How to Restore](#arrows_counterclockwise-how-to-restore)
34
39
-[:star: Featured on](#star-featured-on)
35
40
-[:heart: Support and Contributions](#heart-support-and-contributions)
41
+
-[How to Contribute](#how-to-contribute)
42
+
-[Development Setup](#development-setup)
43
+
-[Code Style](#code-style)
44
+
-[Questions?](#questions)
36
45
37
46
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
38
47
39
48
</details>
40
49
50
+
<!-- SECTION:features:START -->
51
+
41
52
## :star2: Features
42
53
43
54
* 📁 Each backup is in its own folder named after the current timestamp.
@@ -49,6 +60,8 @@ It works on Linux, macOS, and Windows (via WSL or Cygwin). The main advantage ov
49
60
* 🧹 Automatically purge old backups based on a configurable expiration strategy.
50
61
* 🔗 "latest" symlink that points to the latest successful backup.
51
62
63
+
<!-- SECTION:features:END -->
64
+
52
65
## :books: Usage
53
66
54
67
To use `rsync-time-machine.py`, you'll need to provide source and destination paths, along with any desired options:
@@ -130,6 +143,8 @@ options:
130
143
131
144
Please refer to the original [`rsync-time-backup`](https://github.com/laurent22/rsync-time-backup) README fora list of options, as they have been preservedin the Python port.
132
145
146
+
<!-- SECTION:installation:START -->
147
+
133
148
## :hammer_and_wrench: Installation
134
149
135
150
To install `rsync-time-machine.py`, simply clone the repository:
@@ -163,10 +182,18 @@ and use it like `./rsync_time_machine.py --help`
163
182
164
183
For more examples and detailed usage instructions, please refer to the original [`rsync-time-backup`](https://github.com/laurent22/rsync-time-backup) README.
165
184
185
+
<!-- SECTION:examples:END -->
186
+
187
+
<!-- SECTION:expiration:START -->
188
+
166
189
## :calendar: Backup Expiration Logic
167
190
168
191
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.
169
192
193
+
<!-- SECTION:expiration:END -->
194
+
195
+
<!-- SECTION:exclusion:START -->
196
+
170
197
## :page_facing_up: Exclusion File
171
198
172
199
An optional exclude file can be provided as a third parameter, compatible with the `--exclude-from` parameter of rsync.
@@ -210,18 +237,34 @@ See [this tutorial](https://web.archive.org/web/20230126121643/https://sites.goo
210
237
211
238
</details>
212
239
240
+
<!-- SECTION:exclusion:END -->
241
+
242
+
<!-- SECTION:lock:START -->
243
+
213
244
## :lock: Built-in Lock
214
245
215
246
The script is designed so that only one backup operation can be active for a given directory, avoiding conflicts.
216
247
248
+
<!-- SECTION:lock:END -->
249
+
250
+
<!-- SECTION:rsync-options:START -->
251
+
217
252
## :gear: Rsync Options
218
253
219
254
To display, add, or remove rsync options, use the `--rsync-get-flags`, `--rsync-append-flags`, or `--rsync-set-flags` options.
220
255
256
+
<!-- SECTION:rsync-options:END -->
257
+
258
+
<!-- SECTION:no-auto-expire:START -->
259
+
221
260
## :no_entry_sign: No Automatic Backup Expiration
222
261
223
262
Use the `--no-auto-expire` flag to disable the default behavior of purging old backups when out of space.
224
263
264
+
<!-- SECTION:no-auto-expire:END -->
265
+
266
+
<!-- SECTION:restore:START -->
267
+
225
268
## :arrows_counterclockwise: How to Restore
226
269
227
270
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:
@@ -234,14 +277,63 @@ Consider using the `--dry-run` option to check what exactly is going to be copie
234
277
235
278
You can also restore files using any file explorer, including Finder on macOS or the command line.
236
279
280
+
<!-- SECTION:restore:END -->
281
+
282
+
<!-- SECTION:featured:START -->
283
+
237
284
## :star: Featured on
238
285
239
286
- the Real Python podcast: [Episode 158: Building Python CI With Docker & Applying for a Hacker Initiative Grant @ 00:26:28](https://realpython.com/podcasts/rpp/158/#t=1588)
240
287
- Y Combinator Hacker News: [Python Port of 600 Line Bash Script: rsync-time-machine.py for Rsync Backups](https://news.ycombinator.com/item?id=35933238) (self-posted)
241
288
- Reddit /rpython: [Ported a popular (untested) 600+ Line Bash Script 📜 to Python 🐍: Introducing rsync-time-machine.py for Time Machine-Style Backups Using Rsync 🔄⏰](https://www.reddit.com/r/Python/comments/13gtmz2/ported_a_popular_untested_600_line_bash_script_to/) (self-posted)
242
289
290
+
<!-- SECTION:featured:END -->
291
+
292
+
<!-- SECTION:support:START -->
293
+
243
294
## :heart: Support and Contributions
244
295
245
296
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.
246
297
298
+
<!-- SECTION:support:END -->
299
+
300
+
<!-- SECTION:contributing:START -->
301
+
302
+
## How to Contribute
303
+
304
+
1. **Report Issues**: Found a bug or have a feature request? [Open an issue](https://github.com/basnijholt/rsync-time-machine.py/issues)
305
+
2. **Submit Pull Requests**: Bug fixes and new features are welcome
306
+
3. **Improve Documentation**: Help us make the docs better
rsync-time-machine uses an intelligent backup expiration strategy to manage disk space while keeping important historical snapshots.
8
+
9
+
## Backup Expiration Logic
10
+
11
+
<!-- CODE:START -->
12
+
<!-- from generate import readme_section -->
13
+
<!-- print(readme_section("expiration")) -->
14
+
<!-- CODE:END -->
15
+
<!-- OUTPUT:START -->
16
+
<!-- ⚠️ This content is auto-generated by `markdown-code-runner`. -->
17
+
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.
18
+
19
+
<!-- OUTPUT:END -->
20
+
21
+
## No Automatic Backup Expiration
22
+
23
+
<!-- CODE:START -->
24
+
<!-- from generate import readme_section -->
25
+
<!-- print(readme_section("no-auto-expire")) -->
26
+
<!-- CODE:END -->
27
+
<!-- OUTPUT:START -->
28
+
<!-- ⚠️ This content is auto-generated by `markdown-code-runner`. -->
29
+
Use the `--no-auto-expire` flag to disable the default behavior of purging old backups when out of space.
<!-- ⚠️ This content is auto-generated by `markdown-code-runner`. -->
13
+
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.
14
+
15
+
<!-- OUTPUT:END -->
16
+
17
+
<!-- CODE:START -->
18
+
<!-- from generate import readme_section -->
19
+
<!-- print(readme_section("contributing")) -->
20
+
<!-- CODE:END -->
21
+
<!-- OUTPUT:START -->
22
+
<!-- ⚠️ This content is auto-generated by `markdown-code-runner`. -->
23
+
1.**Report Issues**: Found a bug or have a feature request? [Open an issue](https://github.com/basnijholt/rsync-time-machine.py/issues)
24
+
2.**Submit Pull Requests**: Bug fixes and new features are welcome
25
+
3.**Improve Documentation**: Help us make the docs better
0 commit comments