12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'manifests/repo.pp', line 12
define backup::repo (
String $source,
String $target,
String $watchdog_url,
String $password,
Integer $keep_dailies = 5,
Integer $keep_weeklies = 4,
Hash[String, String] $environment = {},
Array[String] $args = ['--cleanup-cache', '-orclone.args=serve restic --addr 127.0.0.1:0 --stdio --use-mmap'],
Optional[String] $rclone_config = undef,
) {
include backup
$init_env = [
"RESTIC_REPOSITORY=${target}",
"RESTIC_PASSWORD=${password}",
"RCLONE_CONFIG=/etc/restic/rclone/${name}",
] + $environment.map |$key, $value| { "${key}=${value}" }
file { "/etc/restic/${name}":
ensure => file,
content => template('backup/environment.erb'),
}
file { "/etc/restic/environment/${name}":
ensure => file,
content => template('backup/environment.erb'),
}
-> exec { "restic-init-${name}":
command => '/usr/bin/restic init',
environment => $init_env,
unless => '/usr/bin/restic snapshots',
}
-> service { "restic@${name}.timer":
ensure => running,
enable => true,
}
file { "/etc/restic/environment/${name}.source":
ensure => file,
content => template('backup/environment.source.erb'),
}
if $rclone_config != undef {
file { "/etc/restic/rclone/${name}":
ensure => file,
content => $rclone_config,
before => Exec["restic-init-${name}"],
}
}
service { "prune-restic@${name}.timer":
ensure => stopped,
enable => false,
}
}
|