Help needed on expanding an existing script for automating zfs snapshots to removable media

Hello guys,

as this is such an helpfull and kind community I thought, I maybe could ask for some help here on a task I was assigned. I found a nice script that mostly does what we want. But I have to automate the snapshoting on a proxmox server further thus I 'd like to adapt the following script to our needs.

First thing is we need to do the backups on an encrypted pool, so adding a line with:
zfs load-key $BACKUPPOOL is easy but as we want to put the script in a cronjob I’d like to know how I can put the password in a variable or hardcode it into the script so there is no prompt asking for it.

Secondly - and that seems a bit more complicated, I’d like to know howto expand the script so it would be possible to also ssh to two remote proxmox servers to do the same as the script does locally, meaning taking snapshots of defined vm-disks and sending them through ssh back to the local server while keeping a number of $KEEPOLD of the snapshots.

Finally - in our setup we have no datasets for the vm-disks but rather created them directly on the pool.

But the script expects poolname\datasetname\vm-disk-xyz-disk-0 whereas we for now have poolname\vm-disk-xyz-disk-0 but if its easier I can create a dataset named disks and move the vm-disks there and modify the ProxMox vmconfigs instead of modifying the logic of the script if necessary.

I would be very glad/thankfull, if you guys could give me a hand on that one! :innocent:

Could I kindly ask for some hint to push me to the right direction on above request? :blush:

I know nothing about ZFS so take it with a grain of salt… and sorry for the block-of-text

man zfs

load-key [- nr ] [- L keylocation ] - a | filesystem
-L keylocation
Use keylocation instead of the keylocation property. This will not change the value of the property on the dataset. Note that if used with either - r or - a keylocation may only be given as prompt

zfs send
zfs receive

Example of zfs load-key and password. To interact with prompts from scripts, expect.
https://jrs-s.net/2016/09/15/zfs-snapshots-and-cold-storage/

Also heard of sanoid / syncoid.