Live data from Hacker News

Python Port of 600 Line Bash Script: rsync-time-machine.py for Rsync Backups

github.com

1–10 of 19 posts

Re: Python Port of 600 Line Bash Script: rsync-time-machine.py for Rsync Backups

#2
Hi Hacker News,

I'm excited to share my recent project, where I took on the challenge of porting a popular but untested 600+ line Bash script to Python. The outcome is [`rsync-time-machine.py`](https://github.com/basnijholt/rsync-time-machine.py), a Python implementation of the [`rsync-time-backup`](https://github.com/laurent22/rsync-time-backup) script. It provides Time Machine-style backups using rsync and creates incremental backups of files and directories to the destination of your choice.

The tool is designed to work on Linux, macOS, and Windows (via WSL or Cygwin). Its advantage over Time Machine is its flexibility - it can backup from/to any filesystem and works on any platform. You can also backup to a Truecrypt drive without any issues.

Unlike the original Bash script, `rsync-time-machine.py` is fully tested. It has no external dependencies (only requires Python ≥3.7), and it is fully compatible with [`rsync-time-backup`](https://github.com/laurent22/rsync-time-backup). It offers pretty terminal output and is fully typed.

Key features include:

* Each backup is in its own folder named after the current timestamp. * Backup to/from remote destinations over SSH. * Files that haven't changed from one backup to the next are hard-linked to the previous backup, saving space. * Safety check - the backup will only happen if the destination has explicitly been marked as a backup destination. * Resume feature - if a backup has failed or was interrupted, the tool will resume from there on the next backup. * Exclude file - support for pattern-based exclusion via the `--exclude-from` rsync parameter. * Automatically purge old backups based on a configurable expiration strategy. * "latest" symlink that points to the latest successful backup.

To learn more about how to use and install `rsync-time-machine.py`, check out the [GitHub repo](https://github.com/basnijholt/rsync-time-machine.py).

I appreciate any feedback and contributions! Feel free to file an issue on the GitHub repository for any bugs, suggestions, or improvements. Looking forward to hearing your thoughts.

Happy backing up!

Please, do let me know if you have any questions or need any further information.

Re: Python Port of 600 Line Bash Script: rsync-time-machine.py for Rsync Backups

#3
I used the bash rsync-time-backup script for a while to back up datasets because they use less space than a full copy by linking to unchanged files in previous backups. Now I am using DVC that takes a git-like approach to do the same, and additionally making it easier to distribute datasets with a simple pull command.

Re: Python Port of 600 Line Bash Script: rsync-time-machine.py for Rsync Backups

#4

Hi Hacker News, I'm excited to share my recent project, where I took on the challenge of porting a popular but untested 600+ line Bash script to Python. The outcome is [`rsync-time-machine.py`]( https://github.com/basnijholt/rsync-time-machine.py ), a Python implementation of the [`rsync-time-backup`]( https://github.com/laurent22/rsync-time-backup ) script. It provides Time Machine-style backups using rsync and crea…

The description sounds like it does largely the same job as rsnapshot (https://rsnapshot.org/). What does yours do differently from rsnapshot?

Re: Python Port of 600 Line Bash Script: rsync-time-machine.py for Rsync Backups

#5
post #4

Hi Hacker News, I'm excited to share my recent project, where I took on the challenge of porting a popular but untested 600+ line Bash script to Python. The outcome is [`rsync-time-machine.py`]( https://github.com/basnijholt/rsync-time-machine.py ), a Python implementation of the [`rsync-time-backup`]( https://github.com/laurent22/rsync-time-backup ) script. It provides Time Machine-style backups using rsync and crea…

The description sounds like it does largely the same job as rsnapshot ( https://rsnapshot.org/ ). What does yours do differently from rsnapshot?

Rsnapshot needs perl? Not available by default on all systems?

Re: Python Port of 600 Line Bash Script: rsync-time-machine.py for Rsync Backups

#6
I'll check this out!

Looks good, and havent come across it before!

Despite constantly Googling for backup solutions and replacements for TimeMachine!

Side note: I recently put together a TrueNAS Scale based NAS box for TimeMachine.

It's running 5x 4TB drives, using ZFS RAIDZ1, and it's the best network multi-user TimeMachine destination I've ever used! (short of a large direct connected TB SSD)

It's much more responsive to browse and restore over my LAN than I'd have expected!

Re: Python Port of 600 Line Bash Script: rsync-time-machine.py for Rsync Backups

#8

How difficult do you think it would be to implement such a system in pure python? This is neat, but it still leverages a lot of shell commands, ie ssh, find, mkdir etc..

I attempted doing this initially. Everything is very doable except SSH. One would have to rely on third-party libraries to do this well.

Re: Python Port of 600 Line Bash Script: rsync-time-machine.py for Rsync Backups

#9
I bet it was a fun project, but in reality backups using rsync vs restic, borg, etc., are very inefficient in speed, performance, storage, and likely other ways. After discovering these newer tools, I vowed to never put myself through the pain of rsync backups ever again.
Post reply on HN