-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement snapshot replication. #41
base: master
Are you sure you want to change the base?
Conversation
0ea3552
to
6ece8a0
Compare
I would just like to point out @mk01's fork of zfs-auto-snapshot. It has an implementation of snapshot replication with some nice options:
Maybe it's not the right fit for the official distribution of zfs-auto-snapshot but thought it is worth mentioning. |
Diffing the two, @mk01 basically rewrote the whole thing.. Which makes it impossible to merge. |
6ece8a0
to
9183d3f
Compare
OK. Thank you for taking a look. |
Having options to I still haven't decided if the fallback is a good idea or not. It's usually only used once (the first time) and this tool seems more towards incrementals (a snapshot IS after all an incremental change - from the previous one). It's not a difficult change, but I just don't know if it's a good idea. Could @wankdanker and/or @kpande give me some examples where this is used (often)? |
Then why don't you use |
Ok, fair enough. It's an easy change anyway. |
In sending snapshots offsite it's best for us to only send the incremental changes over the internet. But if that fails, we still need to get the latest snapshot sent offsite, so destroy whatever is on the remote side and send full. That's our use case. |
dfdfe07
to
a955674
Compare
I agree with @kpande on the option to not create snapshots and just send at least the most recent ones. It would be nice to have a --send-only or --skip-snapshots option that would bypass creating new snapshots and just send the most recently created ones. |
As I just said to @kpande on IRC, I'm not sure that zfs-auto-snapshot is the tool for that... It's called '...snapshot' after all. Having simple replication is good, but I don't think it's in the tools ... 'mission statement' to do such advanced replication.. It handles snapshots. That's it's name, it's purpose. Having ANY replication at all might be to much for the tool in the first place. Which is why I've tried to keep it simple. For those that want/need such advanced replication as you request, you should use a tool specifically geared towards replication. |
I hear you. And I agree with you than any replication at all should technically be out of the scope of the project based on its name. It's just so tempting to want it all in one tool. :) |
Note that ALL my commits in this PR is based on what's on the local system. It assumes that the receiving end is identical to localhost. if the remote end deletes and creates snapshots on it's own, my commits will fail anyway. |
|
Yeah, that's the lazy sysadmin in me. Sounds like its time for zfs-auto-replicate. :) |
The fact that there is (limited) support for replication is enough (for me). But if @dajhorn chooses to rename it and make it into a fully fledged backup and replication tool for ZFS, I might help out where needed. But as I've said, I don't really want that to happen. One tool, one job/purpose. That's the UNIX way :) |
Having support for multiple receiving host is, as you say, easy. BUT, and it's a big but. It still require that each receiver is identical to the sender... |
If you want support for differences between sender and receiver, it's going to be a huge change. I might consider it if (when! :) @dajhorn have merged these ones. But as you say, he's been 'lost' somewhere... |
Yet, your receiver(s) isn't. Because you use a hacked script? I really don't understand why your receiver(s) is so different, but if a snapshot is created on sender/localhost it, and only it, should be sent to the receiver(s)... |
I THINK that if the receiver(s) have come out of sync with the sender/localhost/master (whatever one should call it), it should be up to the administrator to manually fix this before using an auto tool. |
Ah, ok. I think I get it now. Because you have two receivers, but zfs-auto-snapshot can only send to one at a time, zfs-auto-snapshot creates the inconsistency… Ok, fair enough. I'll add support for sending to multiple hosts. As I said, that part is fairly easy. Give me a couple of minutes. |
What options would |
I can see the complication that adding The way I see it, when I think it might be more clear to call this option |
At the moment, I can't see That in addition to the check we're already doing by comparing the local list of snapshots. |
Example usage might be: $ zfs-auto-snapshot --send-incr=remote-server:remote-pool --send-only --send-fallback // Here is what would happen:
So, no new snapshots are created, only the most recent snapshots for each target are sent to remote-server. |
I just skimmed the code, so I am probably missing some of the additional complications. But, it doesn't seem like it is necessary to get a list of remote snapshots and file systems. For each most recent snapshot on localhost, attempt to send it to the remote. You are checking to see if it exists before sending anyway. I'll dig deeper into your code and see if I can implement my vision. |
Yes, but it should only do that if the sender and receiver is not in sync. This is what zfs-auto-snapshot do now:
This is quite simple, and should work. It's not bullet proof, but if there's a failure, I still think it needs manual administrator fixing. IF one would implement
and it might even be more complicated than that. Need to think about this some more. |
No it doesn't. |
a955674
to
5daa3dc
Compare
So in practice, the only think not implemented from @mk01's version is the Anything else? |
6e89625
to
1468d67
Compare
See wankdanker@7ad3100 for what I was picturing for --send-only. It generated the send command as I expected for something like: $ ./zfs-auto-snapshot.sh -v -n --send-incr=bu01:test --send-only --send-fallback --label=hourly ms03-ssd/vm01-disk |
1468d67
to
a0c67c5
Compare
@wankdanker Thanx! Looks good. I've merged that into this PR if you don't mind. If you do, let me know and I'll remove it (it's still marked as yours). |
@FransUrbo that's great, thank you. I didn't get the impression that @mk01's It looks like you handle that with the The one nice addition using the |
a0c67c5
to
3b29896
Compare
This allows a --send-incr to fallback to --send-full if it can't find an earlier snapshot.
Used for skipping snapshotting and only do the replication part.
3b29896
to
6d73a13
Compare
@wankdanker I broke out the part that gets the last snapshot into it's own function (see FransUrbo@3b0e383#diff-e7f2480c37404caadf77e766166e1b3aR155) and then your addition was simple (see FransUrbo@705ec33#diff-e7f2480c37404caadf77e766166e1b3aR270). |
on remote host(s) which is destroyed on localhost.
6d73a13
to
074b2e7
Compare
Awesome work, @FransUrbo. 👍 🍻 |
how can it be used to send backups via cron automatically? |
Not actually tested, other than in dry-run mode. But the commands it would run seems to be correct.
Sign-off: Turbo Fredriksson [email protected]
Closes: #5