2021-06-04 00:38:56 +00:00
|
|
|
# Copyright (C) 2021 Kris Lamoureux
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, version 3 of the License.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
- name: Install rsnapshot
|
2023-05-04 03:27:03 +00:00
|
|
|
ansible.builtin.apt:
|
2021-06-04 00:38:56 +00:00
|
|
|
name: rsnapshot
|
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Create rsnapshot system directories
|
2023-05-04 03:27:03 +00:00
|
|
|
ansible.builtin.file:
|
2021-06-04 00:38:56 +00:00
|
|
|
path: "{{ item }}"
|
|
|
|
state: directory
|
|
|
|
loop:
|
|
|
|
- "{{ rsnapshot_confdir }}"
|
|
|
|
- "{{ rsnapshot_logdir }}"
|
|
|
|
|
|
|
|
- name: Create snapshot_root directories
|
2023-05-04 03:27:03 +00:00
|
|
|
ansible.builtin.file:
|
2021-06-04 00:38:56 +00:00
|
|
|
path: "{{ item.root | default(rsnapshot_root) }}"
|
|
|
|
state: directory
|
|
|
|
loop: "{{ rsnapshot }}"
|
|
|
|
|
|
|
|
- name: Install rsnapshot configuration
|
2023-05-04 03:27:03 +00:00
|
|
|
ansible.builtin.template:
|
2021-06-04 00:38:56 +00:00
|
|
|
src: rsnapshot.conf.j2
|
|
|
|
dest: "{{ rsnapshot_confdir }}/{{ item.name }}.conf"
|
|
|
|
loop: "{{ rsnapshot }}"
|
|
|
|
|
|
|
|
- name: Install rsnapshot crons
|
2023-05-04 03:27:03 +00:00
|
|
|
ansible.builtin.cron:
|
2021-06-04 00:38:56 +00:00
|
|
|
name: "{{ item.1.interval }} rsnapshot of {{ item.0.name }}"
|
2021-06-08 04:33:55 +00:00
|
|
|
job: "/usr/bin/rsnapshot -c {{ rsnapshot_confdir }}/{{ item.0.name }}.conf {{ item.1.interval }} >/dev/null"
|
2021-06-04 00:38:56 +00:00
|
|
|
user: "root"
|
|
|
|
minute: "{{ item.1.minute | default('*') }}"
|
2021-06-04 23:24:27 +00:00
|
|
|
hour: "{{ item.1.hour | default('*') }}"
|
2021-06-04 00:38:56 +00:00
|
|
|
day: "{{ item.1.day | default('*') }}"
|
|
|
|
weekday: "{{ item.1.weekday | default('*') }}"
|
|
|
|
month: "{{ item.1.month | default('*') }}"
|
|
|
|
cron_file: "rsnapshot-{{ item.0.name }}"
|
|
|
|
with_subelements:
|
|
|
|
- "{{ rsnapshot }}"
|
|
|
|
- cron
|
2021-06-08 04:33:55 +00:00
|
|
|
|
|
|
|
- name: Install rsnapshot report script
|
2023-05-04 03:27:03 +00:00
|
|
|
ansible.builtin.template:
|
2021-06-08 04:33:55 +00:00
|
|
|
src: rsnapshot-report.sh.j2
|
|
|
|
dest: /usr/local/bin/rsnapshot-report
|
|
|
|
mode: '0750'
|
|
|
|
|
|
|
|
- name: Install rsnapshot report crons
|
2023-05-04 03:27:03 +00:00
|
|
|
ansible.builtin.cron:
|
2021-06-08 04:33:55 +00:00
|
|
|
name: "{{ item.name }} rsnapshot report email"
|
|
|
|
job: "/usr/local/bin/rsnapshot-report {{ rsnapshot_reportlog }}
|
|
|
|
| mail -s '{{ item.report.subject | default('Backup Report') }}' {{ item.report.to }}"
|
|
|
|
user: "root"
|
|
|
|
minute: '0'
|
|
|
|
hour: '0'
|
|
|
|
cron_file: "rsnapshot-{{ item.name }}"
|
|
|
|
loop: "{{ rsnapshot }}"
|
|
|
|
when: item.report is defined
|