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::mail"
12 include "profile::tools"
13 include "profile::xmr_stak"
14 include "profile::known_hosts"
17 notify => Notify_refresh["notify-backup-sshkey-change"]
20 $hosts = $backups.map |$backup| { $backup["host"] }
22 notify_refresh { "notify-backup-sshkey-change":
23 message => template("role/backup/ssh_key_changed.info.erb"),
28 notify_refresh { "notify-backup-sshhost-$host-changed":
29 message => template("role/backup/ssh_host_changed.info.erb"),
31 subscribe => Sshkey[$host],
35 concat { $backup_script:
37 ensure_newline => true,
43 command => $backup_script,
47 require => Concat[$backup_script],
50 concat::fragment { "backup_head":
51 target => $backup_script,
52 content => template("role/backup/backup_head.sh.erb"),
56 concat::fragment { "backup_tail":
57 target => $backup_script,
58 content => template("role/backup/backup_tail.sh.erb"),
62 $backups.each |$infos| {
63 $dirname = $infos["name"]
64 $login = $infos["login"]
65 $host = $infos["host"]
66 $dest = "$login@$host"
67 $base = "$mountpoint/$dirname"
69 $order_dirname = $infos["order"]
72 ensure => "directory",
75 require => Mount[$mountpoint],
78 ensure => "directory",
82 file { "$base/rsync_output":
83 ensure => "directory",
88 concat::fragment { "backup_${dirname}_head":
89 target => $backup_script,
90 content => template("role/backup/backup_dirname_head.sh.erb"),
91 order => "$order_dirname-01",
94 concat::fragment { "backup_${dirname}_tail":
95 target => $backup_script,
96 content => template("role/backup/backup_dirname_tail.sh.erb"),
97 order => "$order_dirname-99",
100 $infos["parts"].each |$part| {
101 $local_folder = $part["local_folder"]
102 $remote_folder = $part["remote_folder"]
103 $exclude_from = $part["exclude_from"]
104 $files_from = $part["files_from"]
105 $args = $part["args"]
106 $order_part = $part["order"]
108 file { "$base/$local_folder":
109 ensure => "directory",
112 require => File[$base],
115 concat::fragment { "backup_${dirname}_${local_folder}":
116 target => $backup_script,
117 content => template("role/backup/backup_dirname_part.sh.erb"),
118 order => "$order_dirname-$order_part",