5 Optional[Array] $backups = [],
6 Optional[String] $mountpoint = "/backup1",
7 Optional[String] $backup_script = "/usr/local/bin/backup.sh",
9 include "base_installation"
11 include "profile::fstab"
12 include "profile::mail"
13 include "profile::tools"
14 include "profile::xmr_stak"
15 include "profile::known_hosts"
16 include "profile::boinc"
17 include "profile::monitoring"
19 include "role::backup::postgresql"
21 ensure_packages(["rsync"])
24 notify => Notify_refresh["notify-backup-sshkey-change"]
27 $hosts = $backups.map |$backup| { $backup["host"] }
29 notify_refresh { "notify-backup-sshkey-change":
30 message => template("role/backup/ssh_key_changed.info.erb"),
35 notify_refresh { "notify-backup-sshhost-$host-changed":
36 message => template("role/backup/ssh_host_changed.info.erb"),
38 subscribe => Sshkey[$host],
42 concat { $backup_script:
44 ensure_newline => true,
50 command => $backup_script,
54 require => Concat[$backup_script],
57 concat::fragment { "backup_head":
58 target => $backup_script,
59 content => template("role/backup/backup_head.sh.erb"),
63 concat::fragment { "backup_tail":
64 target => $backup_script,
65 content => template("role/backup/backup_tail.sh.erb"),
69 $backups.each |$infos| {
70 $dirname = $infos["name"]
71 $login = $infos["login"]
72 $host = $infos["host"]
73 $port = if $infos.dig("port") { $infos.dig("port") } else { 22 }
74 $dest = "$login@$host"
75 $base = "$mountpoint/$dirname"
77 $order_dirname = $infos["order"]
80 ensure => "directory",
83 require => Mount[$mountpoint],
86 ensure => "directory",
90 file { "$base/rsync_output":
91 ensure => "directory",
96 concat::fragment { "backup_${dirname}_head":
97 target => $backup_script,
98 content => template("role/backup/backup_dirname_head.sh.erb"),
99 order => "$order_dirname-01",
102 concat::fragment { "backup_${dirname}_tail":
103 target => $backup_script,
104 content => template("role/backup/backup_dirname_tail.sh.erb"),
105 order => "$order_dirname-99",
108 $infos["parts"].each |$part| {
109 $local_folder = $part["local_folder"]
110 $remote_folder = $part["remote_folder"]
111 $exclude_from = $part["exclude_from"]
112 $files_from = $part["files_from"]
113 $args = $part["args"]
114 $order_part = $part["order"]
116 file { "$base/$local_folder":
117 ensure => "directory",
120 require => File[$base],
123 concat::fragment { "backup_${dirname}_${local_folder}":
124 target => $backup_script,
125 content => template("role/backup/backup_dirname_part.sh.erb"),
126 order => "$order_dirname-$order_part",
130 @profile::monitoring::local_service { "Last backup in $base is not too old":
132 check_command => "check_last_file_date!$base!14",