Time Machine-style Backups with rsync (2018) - Comments

Time Machine-style Backups with rsync (2018)

mrtesthah

Isn’t restic better for backups overall?

Anyone have a good script for macOS triggered by launchd, ideally something that uses FSEvents to check for directory changes?

crossroadsguy

Yes, it is; among a few other great cross-platform FOSS tools that are built just for backups, and they do it really well. But most of them do periodic scans (as opposed to file change trigger-based backup runs, which I guess is what you might be looking for, I assume by your second sentence).

movetheworld

I use restic, too, and I am very pleased with it, although I run it on windows, which works, but isn't perfect. So, you use it regularly?

nightshift1

Seems similar to https://rsnapshot.org/

kunjanshah

This is the more robust way to go. Uses rsync under the hood.

pmontra

I've been using snapshot for backups since so many years that I forgot when I started. I keep the last 14 snapshots.

nine_k

If we spoke about a Linux box, one that prudently ran ZFS, or XFS on top of LVM, it would be possible to make a snapshot before the diffing and sending, so that the snapshot would be indeed point-in-time. IDK if whatever macOS uses for the filesystem supports snapshots.

Otherwise, I think, restic or kopia are better for proper backups, and Syncthing for keeping a mirror copy. But the simplicity of this script in charming.

wrs
orev

The original post that introduced this idea into general public: http://www.mikerubel.org/computers/rsync_snapshots/

I’m sure others will chime in that they used hard links like this before then, however as noted in that page, it’s the one that made it popular enough that rsync was updated to support the idea natively.

hughc

I've been using a bash encapsulation of this for a long time, works great.

https://github.com/laurent22/rsync-time-backup

EGreg

Why make hard links when you can use rsync or syncthing to just make an actual copy on an external hard drive eg via wifi or just remotely?

kej

The hard links are to the most recent backup before the one happening now in the script, so that you aren't storing full copies of files that haven't changed between backups.

c0nsumer

Hard links are file level dedupe.

And then once all references to the inode are removed (by rotating out backups) it's freed. So there's no maintenance of the deduping needed, it's all just part of how the filesystem and --link-dest work together.

00deadbeef

It does make an actual copy but then it builds a directory structure that you can browse by date (like Time Machine). That directory contains hard links so only one copy of a file is ever backed up but you see contents that match the date of the backup.

c0nsumer

Ha. That's a throwback.

I did the same thing, but with a more detailed writeup, in 2009: https://nuxx.net/blog/2009/12/06/time-machine-for-freebsd/

It was really handy, but I now use borg as it just works better.

human_llm

HA! It read your post I read back then and I have been using it ever since. So thank you. I guess I need to check out borg ;)

theteapot

Need to combine this with LVM or BTRFS or similar to be a true snapshot. Rsnapshot supports LVM snapshot pretty good.

fenazego

Once you have btrfs you don't really need rsync anymore, its snapshot + send/receive functionality are all you need for convenient and efficient backups, using a tool like btrbk.

LeoPanthera

"borg" has basically solved backups permanently. It's deduplicated, even across snapshots, compressed, and end-to-end encrypted. I'm surprised it's not more well known.

locknitpicker

> "borg" has basically solved backups permanently. It's deduplicated, even across snapshots, compressed, and end-to-end encrypted.

Deduplication helps minimize space, but isn't it a major liability in backups? I mean, what happens when you try to restore your backups but a lone sector holding a file from way back in the past happens to not be recoverable? Doesn't it mean that no matter how frequent your backups are, your data is lost?

IshKebab

I used to use Borg, but Restic (and it's Rust clone Rustic) are better.

hcartiaux

I use bontmia since forever, based on the same rsync feature (link-dest for creating hard links to the unmodified files since the last backup). It also supports backup rotation and I think it's quite solid/reliable after all these years: https://github.com/hcartiaux/bontmia

mattbillenstein

restic to s3 has been very reliable - haven't tried borg.

nocman

sounds similar to rdiff-backup ( https://rdiff-backup.net ).

I know some folks that have been using that for a very long time as well.

00deadbeef

Reminds me of a tool I used to use that did a similar thing: https://github.com/jeremywohl/glastree

mrtesthah

Isn’t restic better for backups overall?

Anyone have a good script for macOS triggered by launchd, ideally something that uses FSEvents to check for directory changes?

crossroadsguy

Yes, it is; among a few other great cross-platform FOSS tools that are built just for backups, and they do it really well. But most of them do periodic scans (as opposed to file change trigger-based backup runs, which I guess is what you might be looking for, I assume by your second sentence).

movetheworld

I use restic, too, and I am very pleased with it, although I run it on windows, which works, but isn't perfect. So, you use it regularly?

nightshift1

Seems similar to https://rsnapshot.org/

kunjanshah

This is the more robust way to go. Uses rsync under the hood.

pmontra

I've been using snapshot for backups since so many years that I forgot when I started. I keep the last 14 snapshots.

nine_k

If we spoke about a Linux box, one that prudently ran ZFS, or XFS on top of LVM, it would be possible to make a snapshot before the diffing and sending, so that the snapshot would be indeed point-in-time. IDK if whatever macOS uses for the filesystem supports snapshots.

Otherwise, I think, restic or kopia are better for proper backups, and Syncthing for keeping a mirror copy. But the simplicity of this script in charming.

wrs
orev

The original post that introduced this idea into general public: http://www.mikerubel.org/computers/rsync_snapshots/

I’m sure others will chime in that they used hard links like this before then, however as noted in that page, it’s the one that made it popular enough that rsync was updated to support the idea natively.

hughc

I've been using a bash encapsulation of this for a long time, works great.

https://github.com/laurent22/rsync-time-backup

EGreg

Why make hard links when you can use rsync or syncthing to just make an actual copy on an external hard drive eg via wifi or just remotely?

kej

The hard links are to the most recent backup before the one happening now in the script, so that you aren't storing full copies of files that haven't changed between backups.

c0nsumer

Hard links are file level dedupe.

And then once all references to the inode are removed (by rotating out backups) it's freed. So there's no maintenance of the deduping needed, it's all just part of how the filesystem and --link-dest work together.

00deadbeef

It does make an actual copy but then it builds a directory structure that you can browse by date (like Time Machine). That directory contains hard links so only one copy of a file is ever backed up but you see contents that match the date of the backup.

c0nsumer

Ha. That's a throwback.

I did the same thing, but with a more detailed writeup, in 2009: https://nuxx.net/blog/2009/12/06/time-machine-for-freebsd/

It was really handy, but I now use borg as it just works better.

human_llm

HA! It read your post I read back then and I have been using it ever since. So thank you. I guess I need to check out borg ;)

theteapot

Need to combine this with LVM or BTRFS or similar to be a true snapshot. Rsnapshot supports LVM snapshot pretty good.

fenazego

Once you have btrfs you don't really need rsync anymore, its snapshot + send/receive functionality are all you need for convenient and efficient backups, using a tool like btrbk.

LeoPanthera

"borg" has basically solved backups permanently. It's deduplicated, even across snapshots, compressed, and end-to-end encrypted. I'm surprised it's not more well known.

locknitpicker

> "borg" has basically solved backups permanently. It's deduplicated, even across snapshots, compressed, and end-to-end encrypted.

Deduplication helps minimize space, but isn't it a major liability in backups? I mean, what happens when you try to restore your backups but a lone sector holding a file from way back in the past happens to not be recoverable? Doesn't it mean that no matter how frequent your backups are, your data is lost?

IshKebab

I used to use Borg, but Restic (and it's Rust clone Rustic) are better.

hcartiaux

I use bontmia since forever, based on the same rsync feature (link-dest for creating hard links to the unmodified files since the last backup). It also supports backup rotation and I think it's quite solid/reliable after all these years: https://github.com/hcartiaux/bontmia

mattbillenstein

restic to s3 has been very reliable - haven't tried borg.

nocman

sounds similar to rdiff-backup ( https://rdiff-backup.net ).

I know some folks that have been using that for a very long time as well.

00deadbeef

Reminds me of a tool I used to use that did a similar thing: https://github.com/jeremywohl/glastree