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 "role::cryptoportfolio::postgresql_backup"
19 ensure_packages(["rsync"])
22 notify => Notify_refresh["notify-backup-sshkey-change"]
25 $hosts = $backups.map |$backup| { $backup["host"] }
27 notify_refresh { "notify-backup-sshkey-change":
28 message => template("role/backup/ssh_key_changed.info.erb"),
33 notify_refresh { "notify-backup-sshhost-$host-changed":
34 message => template("role/backup/ssh_host_changed.info.erb"),
36 subscribe => Sshkey[$host],
40 concat { $backup_script:
42 ensure_newline => true,
48 command => $backup_script,
52 require => Concat[$backup_script],
55 concat::fragment { "backup_head":
56 target => $backup_script,
57 content => template("role/backup/backup_head.sh.erb"),
61 concat::fragment { "backup_tail":
62 target => $backup_script,
63 content => template("role/backup/backup_tail.sh.erb"),
67 $backups.each |$infos| {
68 $dirname = $infos["name"]
69 $login = $infos["login"]
70 $host = $infos["host"]
71 $dest = "$login@$host"
72 $base = "$mountpoint/$dirname"
74 $order_dirname = $infos["order"]
77 ensure => "directory",
80 require => Mount[$mountpoint],
83 ensure => "directory",
87 file { "$base/rsync_output":
88 ensure => "directory",
93 concat::fragment { "backup_${dirname}_head":
94 target => $backup_script,
95 content => template("role/backup/backup_dirname_head.sh.erb"),
96 order => "$order_dirname-01",
99 concat::fragment { "backup_${dirname}_tail":
100 target => $backup_script,
101 content => template("role/backup/backup_dirname_tail.sh.erb"),
102 order => "$order_dirname-99",
105 $infos["parts"].each |$part| {
106 $local_folder = $part["local_folder"]
107 $remote_folder = $part["remote_folder"]
108 $exclude_from = $part["exclude_from"]
109 $files_from = $part["files_from"]
110 $args = $part["args"]
111 $order_part = $part["order"]
113 file { "$base/$local_folder":
114 ensure => "directory",
117 require => File[$base],
120 concat::fragment { "backup_${dirname}_${local_folder}":
121 target => $backup_script,
122 content => template("role/backup/backup_dirname_part.sh.erb"),
123 order => "$order_dirname-$order_part",