Skip to content

Support for snapshot sync at mount#69

Open
Musholic wants to merge 7 commits intoccomb:masterfrom
Musholic:snapshot_sync_at_mount
Open

Support for snapshot sync at mount#69
Musholic wants to merge 7 commits intoccomb:masterfrom
Musholic:snapshot_sync_at_mount

Conversation

@Musholic
Copy link

@Musholic Musholic commented Jan 30, 2026

I've implemented the proposal in #68 with a few tests (base mount/umount logics + different usual scenarios). I'm keeping the changes as simple as possible, let me know what you think

The implementation follows this logic:

  • Add a new schedule named "snapshot_sync", which will be used to know if we want to automatically restore newer snapshots at mount. And at unmount, it will automatically snapshot and send it
  • This new schedule will work the same way as replicate, in addition to the mount/unmount logic
  • Support for adding schedules automatically at volume creation: may not be necessary, but it felt really better with it (and this was simple enough to implement). The only downside is that we have to delete the schedules manually if we don't want them anymore, but it should be ok for now
  • Refactor of several functions, especially since I apparently could not reuse directly the route method, which I suffixed with _req
  • Prevent the creation of empty snapshots, as it may conflict if the service is moved to another host, but we kept creating snapshots on other hosts. It's using a quick and efficient check based on btrfs send/receive
  • Prevent sending the same snapshot to the same remote (since we don't necessarily create new snapshots every time we replicate)

I plan to implement the support for multiple hosts in another PR, as I may have to deal with timeouts and connection errors to handle the case where one of the hosts is unresponsive.

I've tested the PR on my own setup, and I think it's ready to be merged. Let me know if you are willing to merge it, and then I can also update the documentation to finish the PR (or in a second PR).

TODO:

  • Document the new "snapshot_sync" schedule and the new "schedules" option
  • Fix snapshot still created on "inactive" hosts

@Musholic Musholic force-pushed the snapshot_sync_at_mount branch 4 times, most recently from 629458b to c3a589f Compare February 2, 2026 21:05
@Musholic Musholic force-pushed the snapshot_sync_at_mount branch from c3a589f to 0d890f1 Compare February 3, 2026 09:39
@Musholic Musholic marked this pull request as ready for review February 3, 2026 09:55
@Musholic Musholic marked this pull request as draft February 3, 2026 10:56
from possible data loss and reduce useless activity)
@Musholic Musholic marked this pull request as ready for review February 3, 2026 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant