Closed michalroxorpl closed 2 years ago
Hi, thanks for the contribution and sorry for the delay. Checking it out right now.
You seem to have found a very simple workaround. Sadly the change isn't backwards-compatible and it would need another task to remove the old cron job or current users will end up with a duplicate cron job, which would be quite bad.
Since we already have the borgmatic_cron_name
variable, is there anything stopping you from setting this variable in your own roles?
I've been also wondering about similar scenario. My approach to solving it was to generate the borgmatic
config files in /etc/borgmatic.d/
instead of in /etc/borgmatic
. Then a single call to borgmatic
will run all those configurations. Thus only one cron file is necessary if it's ok that they run at the same time (one after another).
See https://torsion.org/borgmatic/docs/how-to/make-per-application-backups/
The problem
I intent to run several different backups on same host. Currently it is not possible as after each run the role overwrites same cronjob filename
/etc/cron.d/borgmatic
updating it with only call of the currently processed borgmatic configuration file.The scenario
There are several nextcloud instances hosted on one server. Each resides in separate directory. It is currently possible to create multiple borgmatic configurations to manage backups for all these nextcloud instances, however, after each playbook run, the /etc/cron.d/borgmatic file will be overwritten rendering the whole scenario unusable.
The solution
Instead of using
borgmatic_cron_name
parsing to/etc/cron.d/borgmatic
let's switch to name matching{{ borgmatic_config_name }}
name in the cron job file name:borgmatic_cron_name
parsing to/etc/cron.d/borgmatic-{{ borgmatic_config_name }}
. With this approach we might successfully run the same playbook against one server for multiple backups, considering borgmatic_config_name will be different for each of the configurations.The example
Example on how to approach this using configuration name based on inventory_hostname: