diff --git a/REFERENCE.md b/REFERENCE.md
index c528fb4..93062d3 100644
--- a/REFERENCE.md
+++ b/REFERENCE.md
@@ -60,6 +60,7 @@ The following parameters are available in the `borg` class:
* [`proxy_server`](#proxy_server)
* [`manage_package`](#manage_package)
* [`ssh_key_type`](#ssh_key_type)
+* [`backuptime`](#backuptime)
##### `package_name`
@@ -297,3 +298,11 @@ configure your most favourite ssh key type. This will be used to connect to the
Default value: `'ed25519'`
+##### `backuptime`
+
+Data type: `Hash[String[1],String[1]]`
+
+Configure the name of each backupjob and the time of that job.
+
+Default value: `{ 'default' => '18:30:00' }`
+
diff --git a/manifests/init.pp b/manifests/init.pp
index 8fc6438..34e18ae 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -93,6 +93,9 @@
# @param ssh_key_type
# configure your most favourite ssh key type. This will be used to connect to the remote borg server.
#
+# @param backuptime
+# Configure the name of each backupjob and the time of that job.
+#
# @see https://metacpan.org/pod/App::BorgRestore
#
class borg (
@@ -127,6 +130,7 @@
Optional[String[1]] $proxy_server = undef,
Boolean $manage_package = true,
Enum['rsa', 'ed25519'] $ssh_key_type = 'ed25519',
+ Hash[String[1],String[1]] $backuptime = { 'default' => '18:30:00' },
) {
contain borg::install
contain borg::config
diff --git a/manifests/service.pp b/manifests/service.pp
index 8c84588..d4b587d 100644
--- a/manifests/service.pp
+++ b/manifests/service.pp
@@ -17,9 +17,11 @@
),
}
-> systemd::unit_file { 'borg-backup.timer':
- content => epp("${module_name}/borg-backup.timer.epp"),
- enable => true,
- active => true,
+ content => epp("${module_name}/borg-backup.timer.epp",
+ backuptime => $borg::backuptime
+ ),
+ enable => true,
+ active => true,
}
}
}
diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb
index 71d7cb9..f6fc454 100644
--- a/spec/classes/init_spec.rb
+++ b/spec/classes/init_spec.rb
@@ -125,6 +125,39 @@
it { is_expected.to compile.with_all_deps }
end
+
+ context 'fails without a valid backuptime present' do
+ let :params do
+ {
+ backupserver: 'localhost',
+ backuptime: ''
+ }
+ end
+
+ it { is_expected.not_to compile }
+ end
+
+ context 'with nondefault backuptime present' do
+ let :params do
+ {
+ backupserver: 'localhost',
+ backuptime: { 'default' => '01:00:00' }
+ }
+ end
+
+ it { is_expected.to compile.with_all_deps }
+ end
+
+ context 'with multiple backuptimes present' do
+ let :params do
+ {
+ backupserver: 'localhost',
+ backuptime: { '1 am' => '01:00:00', '2 am' => '02:00:00' }
+ }
+ end
+
+ it { is_expected.to compile.with_all_deps }
+ end
end
end
end
diff --git a/templates/borg-backup.timer.epp b/templates/borg-backup.timer.epp
index 5e934d2..106851e 100644
--- a/templates/borg-backup.timer.epp
+++ b/templates/borg-backup.timer.epp
@@ -1,12 +1,16 @@
+<%- | Hash[String,String] $backuptime,
+| -%>
# THIS FILE IS MANAGED BY PUPPET
[Unit]
-Description=Daily Timer for borg-backup
+Description=Daily Timer(s) for borg-backup
[Timer]
# OnBootSec=10min
# OnUnitActiveSec=1d
-# Daily at 8am
-OnCalendar=*-*-* 18:30:00
+<% $backuptime.each | $jobname, $time | { -%>
+# Daily named job "<%= $jobname %>" at <%= $time %>
+OnCalendar=*-*-* <%= $time %>
+<% } -%>
Persistent=True
[Install]