2020-08-10 01:37:13 +02:00
|
|
|
---
|
2020-09-26 18:12:59 +02:00
|
|
|
# Tasks file for the lvm_self_backup role
|
2020-08-10 01:37:13 +02:00
|
|
|
|
|
|
|
# Infrastructure
|
|
|
|
# Ansible instructions to deploy the infrastructure
|
|
|
|
# Copyright (C) 2020 Saibotk
|
|
|
|
#
|
|
|
|
# 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 <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
- name: Create backup mount directories
|
2022-08-13 17:50:54 +02:00
|
|
|
ansible.builtin.file:
|
2023-10-14 00:18:16 +02:00
|
|
|
path: "/lvm_self_backup_snapshots/{{ item.vg_name }}-{{ item.lv_name }}"
|
2020-08-10 01:37:13 +02:00
|
|
|
state: directory
|
2023-10-14 00:18:16 +02:00
|
|
|
mode: "0700"
|
|
|
|
owner: "root"
|
|
|
|
group: "root"
|
2020-08-10 01:37:13 +02:00
|
|
|
recurse: true
|
|
|
|
with_items:
|
2023-10-14 00:18:16 +02:00
|
|
|
- "{{ lvm_self_backup_vols }}"
|
2020-08-10 01:37:13 +02:00
|
|
|
become: true
|
|
|
|
|
2021-01-02 10:59:22 +01:00
|
|
|
- name: Create backup status directory
|
2022-08-13 17:50:54 +02:00
|
|
|
ansible.builtin.file:
|
2021-01-02 10:59:22 +01:00
|
|
|
path: "{{ item }}"
|
|
|
|
state: directory
|
2023-10-14 00:18:16 +02:00
|
|
|
mode: "0700"
|
|
|
|
owner: "{{ lvm_self_backup_status_directory_uid }}"
|
|
|
|
group: "{{ lvm_self_backup_status_directory_gid }}"
|
2021-01-02 10:59:22 +01:00
|
|
|
recurse: true
|
|
|
|
with_items:
|
2023-10-14 00:18:16 +02:00
|
|
|
- "{{ lvm_self_backup_status_directory }}"
|
2021-01-02 10:59:22 +01:00
|
|
|
become: true
|
|
|
|
|
2020-08-10 01:37:13 +02:00
|
|
|
- name: Install backup scripts.
|
2022-08-13 17:50:54 +02:00
|
|
|
ansible.builtin.template:
|
2020-08-10 01:37:13 +02:00
|
|
|
src: "{{ item.src }}"
|
|
|
|
dest: "{{ item.dest }}"
|
2023-10-14 00:18:16 +02:00
|
|
|
mode: "0700"
|
|
|
|
owner: "root"
|
|
|
|
group: "root"
|
2020-08-10 01:37:13 +02:00
|
|
|
with_items:
|
|
|
|
- src: "backup-lvm.sh"
|
|
|
|
dest: "/usr/local/bin/backup-lvm"
|
|
|
|
- src: "backup-lvm-ls.sh"
|
|
|
|
dest: "/usr/local/bin/backup-lvm-ls"
|
|
|
|
become: true
|
|
|
|
|
2024-02-21 22:25:46 +01:00
|
|
|
- name: Install backup services & timer.
|
2022-08-13 17:50:54 +02:00
|
|
|
ansible.builtin.template:
|
2020-08-10 01:37:13 +02:00
|
|
|
src: "{{ item }}"
|
|
|
|
dest: /etc/systemd/system/
|
2023-10-14 00:18:16 +02:00
|
|
|
mode: "0600"
|
|
|
|
owner: "root"
|
|
|
|
group: "root"
|
2020-08-10 01:37:13 +02:00
|
|
|
with_items:
|
2024-02-21 22:25:46 +01:00
|
|
|
- "backup-error.service"
|
2020-08-10 01:37:13 +02:00
|
|
|
- "backup-lvm.service"
|
|
|
|
- "backup-lvm.timer"
|
2021-11-20 03:30:44 +01:00
|
|
|
notify: Reload systemd config
|
2020-08-10 01:37:13 +02:00
|
|
|
become: true
|
|
|
|
|
|
|
|
- name: Start & enable backup service timer.
|
2022-08-13 17:50:54 +02:00
|
|
|
ansible.builtin.systemd:
|
2021-03-05 13:02:55 +01:00
|
|
|
daemon_reload: true
|
2020-08-10 01:37:13 +02:00
|
|
|
name: backup-lvm.timer
|
2023-10-14 00:18:16 +02:00
|
|
|
enabled: "{{ lvm_self_backup_timer_enabled | bool }}"
|
|
|
|
state: "{{ lvm_self_backup_timer_state }}"
|
2020-08-10 01:37:13 +02:00
|
|
|
become: true
|