Datastore Sync Hook Scripts

Mrt12

Well-Known Member
May 19, 2019
176
21
58
46
CH
Hello,
So I have one PBS Server on-site where all the clients and VMs get backed up. Very nice, super good deduplication and everything.
However, due to obvious reasons, a sync to a remote site is desirable.
I have on purpose for this configured a little Wireguard VPN that I connect to, then run the sync and then disconnect again from the VPN. This work beautifully and I can sync the local datastore to a remote PBS server using an API token and a dedicated namespace, to not mix things that do not belong together.
Currently, to achieve the sync, I made a little bash script, that first connects to the Wireguard VPN (using wg-quick), thn runs the datastore sync command from PBS, and then disconnects from the VPN again. I don't want the VPN connection to stay open longer than necessary.

When setting this up, I found it would be super convenient if the Proxmox Web GUI would offer the option to add pre-/post sync hook scripts, in this way, actions like connecting to a VPN and such could be performed before the sync starts.

Is there maybe already somehow the possibility, or could this be an interesting feature?
 
I don't want the VPN connection to stay open longer than necessary.
Understandably, but what about building it the other way around:

Connecting the tunnel from the destination side, running the sync job and the disconnecting it again? This is (without error handling) a 3 line bash script.
Pulling is in general considered safer, because an attacker cannot control this from the source.
 
  • Like
Reactions: Johannes S and UdoB
yes, this would work also, but still does not really solve the problem that some kind of pre/post-sync hook is required. Also the current implementation with pushing (rather than pulling) is a 3 line bash script, and it works well, but the disadvantage is that I cannot manage this particular sync job from the web GUI, because if the sync job is run from the web GUI, I first need to connect to the VPN and disconnect after it's done, but this is not possible.

So I set in the web GUI the schedule to "none", and then call the bash script from cron, that first connects the VPN, then manually starts the sync, and then disconnects. It would have been much nicer if all of these steps were visible in the web GUI, because if changes are made in the web GUI for whatever reason, these are not necessarily reflected into the bash script (and can be forgotten easily, for example).