Show HN: Btrsync – btrfs snapshot replication made easy
tl;dr:
btrsync is rsync but for btrfs snapshots;
you type in source &amp; destination, it figures out everything else;
check it out at <a href="https:&#x2F;&#x2F;github.com&#x2F;andreittr&#x2F;btrsync">https:&#x2F;&#x2F;github.com&#x2F;andreittr&#x2F;btrsync</a><p># Background<p>I&#x27;ve been using btrfs for nearly a decade now, setting up daily or even hourly automatic snapshots of various parts of my system. Being able to go back in time is great for when I mess something up and forget how I got there. That happens. Snapshots also happen to be a good starting point for backups.<p>Snapshots aren&#x27;t really backups until you transfer them off-device and put that other device somewhere else (ideally offline and off-site). Luckily, btrfs has incremental `send` and `receive` to handle this. You just tell `send` what volume to use as a base and you have incremental transfers, magic!. Assuming the same base volume is there on the `receive` end. And I mean the <i>exact</i> same. Fair enough, so I got btrfs on external storage and proceeded with backing up.<p>At first, shell one-liners and basic scripts worked out well...-ish. String processing in shell scripts is cursed, so I pulled out Python, leading to the first incarnation of `btrsync.py`.<p>But edge cases kept popping up, and constantly babysitting the process got tedious fast, there had to be a better way. An automatic way.
Looking around, there were some btrfs automation tools out there, even GUIs, but they seemed to focus more on rollback than backup. I also didn&#x27;t want to overhaul my existing snapshotting setup.
What I wanted was something simple that I could invoke on a whim and it would figure out everything, something like rsync, but for btrfs. I was surprised it wasn&#x27;t a thing yet.<p>So, in the spirit of scratching my own itch, I got to work on btrsync v2, a complete rewrite needing a bit less handholding and with shiny new ssh support! Because I couldn&#x27;t be bothered to connect my backup drive to another computer.
I&#x27;m not entirely sure what was going through my head at the time, if anything, but the code was a mess; it would fail mysteriously, hang forever if stuff wouldn&#x27;t finish in the right order, and leave zombie processes around if interrupted at the wrong time. A mess.
But it also kinda worked, heroically handling hundreds of gigabytes of backups with only the occasional diving-down-a-rabbit-hole bug hunt when it misbehaved. It&#x27;s OK, it&#x27;s good, it works, leave it be, I said.<p>But it was not OK, it wasn&#x27;t even close to reliable, and any attempt to fix the code now, years later, feels like archaeology, so it was time to do it properly.
Well, third time&#x27;s the charm, because btrsync round 3 went surprisingly good, hence this post.
Subvolume discovery, diff-ing, parentage, etc. are all handled automatically now, no more handholding, and finally a CLI as simple as rsync or scp.<p>I reckon I can&#x27;t be the <i>only</i> one needing something like this, so after some quick code cleanup, doc writing, and various other admin stuff, I&#x27;ve put btrsync out in the wild. Ready to lend a hand to anyone who, like my past self, just wants something simple and straight-forward to copy their snapshots around.<p>Give it a spin and let me know what you think!