Yes, having multiple snapshot tasks can be sent with just one replication task as long as you add the snapshot names in the replication task.
Thatās not the issue, though.
Having just one replication task doesnāt allow you to set different expiration lengths on different series of snapshots. Iām forced to have multiple replication tasks just so that I can get my backup machine to hold more snapshots than the main machine. The question is then if you can get multiple replication tasks to coexist, and the frustration is that we need to play this game because TrueNAS doesnāt have a feature of ākeep more snapshots on the target machine than on the source machineā and declined it as a feature.
But this is something we definitely have - for a single pair of snapshot and replication tasks.
Right, but I want to do it for more than just a single pair. Thatās what this whole thread has been about. When the thread is āTrueNAS doesnāt support ākeep more snapshots on the target machine than on the source machine for tiered snapshotsāā, a reply of ābut it does support it, just not for tiered snapshotsā doesnāt make sense.
At this point Iām trying to pick between giving up and just using the stock replication so that the snapshots are identical on my remote machine, or wiping my remote machine and going with stock zrepl. Iām not sure which, yet.
Whatās the issue with multiple tasks if you want different retention times?
How would you manage different retention times for different snapshot schemes within a single task? (Cue in some convoluted interfaceā¦)
You can have as many snapshot schemes as you want on the same data. Itās all metadata.
Please try my suggested scheme with three different ānamespacesā.
Iām aware of having multiple snapshot schemes, each with its own retention rule. Thatās TrueNAS 101.
Iām talking about replicating the pool to the remote server, and having different retention rules for the remote server. That is not trivial, and seems to be almost impossible using standard TrueNAS UI.
The only way I can think to do this is to have multiple replication tasks, each with a different āPeriodic Snapshot Tasksā set (so that you can expire them differently) but each replication task including every other taskās snapshots as āAlso include snapshots with the nameā, then in theory, each of the replications should be able to find the snapshots from any other replication that uploaded it, and avoid duplicates.
That is insane, but about the only way I can think I could make it work.
I think youāre referring to
Then create three different replication tasks based on these with yet different retention times on the destination. Again snapshots will only use as much space as necessary to get from one to the next younger one, regardless of the name or by which job they are created.
Thatās what Iām describing. Each replication task needs to be driven off of a different snapshot task, but each replication task needs to include every other replication taskās snapshots as āAlso include snapshots with the nameā. The ādailyā replication task has to send the āweeklyā snapshots so that when the āweeklyā replication task runs, it can see the āweeklyā snapshots in the remote and avoid sending the remote server the data that it already has.
(Again, the weekly replication task has to run, even though the daily task has guaranteed sent all of the data, just to expire the snapshots, because thereās no way to set up an expiration-only snapshot task. If we just got the ability to schedule snapshot deletion without creation, that would solve all of this!)
I have never tried this but I am quite confident it should work.
Thatās what scares me. It seems like no one has dealt with this situation, but is happy to give me advice that they canāt say for sure works. My remote server is on the other side of the world. At the rate that data flows, a replication will take weeks. I canāt risk playing a game of āoh, I set up my replication rules wrong and now TrueNAS is sending the same data three times because the replication system doesnāt realize that the remote system already has it.ā
Thatās not what I suggested. I think three replication tasks each working only on the hourly/weekly/monthly naming scheme would do the trick.
OK, thinking this through.
The hourly replication task runs, and replicates only the hour snapshots. It does this for a week straight.
Then the weekly replication task runs. It hits the line
in which it asks, āwhat data does the remote server have?ā Because (in this scenario) the daily replication task isnāt replicating the weekly snapshots, the weekly replication task thinks that the remote system is a week out of date, and sends a week of data that the remote server already has. My upload link dies.
The reason Iām insisting that each replication task has to send all the snapshots is because I see that line of code. Please correct me if I misunderstand it.
One last completely different approach. Delete old snapshots from CLI | TrueNAS Community led me to GitHub - bahamas10/zfs-prune-snapshots: Remove snapshots from one or more zpools that match given criteria Ā· GitHub.
So the simplest possible thing to do would probably have one replication task, have it push all snapshots, have it not expire any of them, and then set up zfs-prune-snapshots in three cron jobs in the remote server to do the cleanup.
Maybe I donāt get it but do you mean something like this?
That should work, right?
@winnielinnie mind chiming in?
Yes, thatās what I assume how it would be working in practice. I do not have a problem sending a weekās or a monthās worth of data.
So no solution for you. Sorry.
Lucky you; my backup server is a big Hetzner box in Finland, and Iām getting something like 50Mb/s encrypted to it. I genuinely donāt know if I can do better. Is it Tailscale? Lots of small files? The 10 disk RAIDZ2 on the receiving end? This is literally going to be a month.
I set up some cron jobs with zfs-prune-snapshots and I think thatāll do. I do think that easily managing tiered snapshot systems should be easier. Switch to zrepl?
Thanks, all.
This post hits the nail with the hammer.
The TrueNAS way of handling the automation of ZFS snapshots and replications is very narrow in scope. Itās really designed to be used by tethering an automatic snapshot task to a replication task and be done with it. Anything beyond that requires multiple tasks for the same targets (redundant and resends data), or custom scripts, or using the command-line.[1]
I doubt itās going to change anytime soon.
If you want a hint, all you need to do is grab the names of the latest snapshot on the destination and source, and then use the first snapshot name as the ābaseā and the second snapshot name as the āendā. Pass the
-Iparameter (capital āiā) so thatzfs sendwill include all intermediary snapshots. One command, one send that includes all snapshots, no matter their naming schema. The problem is, the source server will not prune snapshots on the destination, since that is handled byzettareplvia the configured Replication Task. Youād have to use another means to prune the snapshots on the destination. ā©ļø
Thanks for the confirmation.
Re your footnote, for sending all the snapshots Iām going for a standard pull but rather than a naming schema, Iām going for āmatching regular expressionā of .* which seems to accomplish what Iām looking for. Iām doing a manual purge using cron jobs.
The real bummer here is that zrepl seems more along the lines of something that Iād want to use, but I canāt figure out a reasonable way of installing it. I donāt think itās very prudent to install it directly (as Run zrepl on TrueNAS | Alan Norbauer does), but you canāt run it inside a VM, nor an LXC, nor a Docker container, so I guess not.
Why that? An SSH connection with public key authentication is as secure as any VPN.
And Hetzner Helsinki, thatās EU, GDPR, as trustworthy as can be
We have a large storage server at their location, too.
Itās not only about security, itās about convenience and ease of use. Because I put the remote server on Tailscale, it can easily connect back into my home network to do pull. Fair point in that it might be worth trying doing a push replication over just ssh to see if itās faster.
Amusingly (or sadly) enough, with 110ms RTT, SSH is slower than Tailscale. See my adventure at Is TrueNAS is shipping an SSH binary that throttles connections over high-latency links?
Time for plan C: zrepl. No VMs or LXCs or Docker containers. This should be doable with a shell script and a cron job. I cannot believe I am forced into doing this due to complete lack of tools on TrueNAS (you had one job, TrueNAS!), but so be it.
Youāre not crazyāTrueNAS/zetta-repl just doesnāt support per-snapshot-type retention on the target side via the UI, so the usual workaround is splitting replication by naming schema or handling retention with custom scripts/zrepl instead.