borg-backup: space out cron jobs evenly

To avoid the backup jobs running over the top of each other, space the
cron jobs out evenly through the day for each server.

Change-Id: I07a096ee130e61e9efc89887d627da8ef829854a
This commit is contained in:
Ian Wienand 2020-11-11 12:57:32 +11:00
parent b05a98440a
commit 93b4c9ed1f

View File

@ -58,9 +58,13 @@
name: "Run borg backup to {{ item }}"
job: "/usr/local/bin/borg-backup {{ item }} 2>> /var/log/borg-backup-{{ item }}.log"
user: root
hour: '5'
# This should space out the backups so they run in a round-robbin
# evenly through the day to each of the different backup servers
hour: '{{ ((5 + ((24 / ansible_loop.length) * ansible_loop.index0 )) % 24) | int}}'
minute: '{{ 59|random(seed=item) }}'
with_inventory_hostnames: borg-backup-server
loop_control:
extended: yes
- name: Install logrotate rules
include_role: