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:
|
2020-08-10 01:37:13 +02:00
|
|
|
path: "/backup_snapshots/{{ item.vg_name }}-{{ item.lv_name }}"
|
|
|
|
state: directory
|
2020-09-26 21:35:58 +02:00
|
|
|
mode: '0700'
|
|
|
|
owner: 'root'
|
|
|
|
group: 'root'
|
2020-08-10 01:37:13 +02:00
|
|
|
recurse: true
|
|
|
|
with_items:
|
|
|
|
- "{{ backup_vols }}"
|
|
|
|
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
|
|
|
|
mode: '0700'
|
2021-10-29 23:46:10 +02:00
|
|
|
owner: "{{ backup_status_directory_uid }}"
|
|
|
|
group: "{{ backup_status_directory_gid }}"
|
2021-01-02 10:59:22 +01:00
|
|
|
recurse: true
|
|
|
|
with_items:
|
|
|
|
- "{{ backup_status_directory }}"
|
|
|
|
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 }}"
|
2020-09-26 21:35:58 +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
|
|
|
|
|
|
|
|
- name: Install backup service & 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/
|
2021-11-20 00:27:19 +01:00
|
|
|
mode: '0600'
|
2020-09-26 21:35:58 +02:00
|
|
|
owner: 'root'
|
|
|
|
group: 'root'
|
2020-08-10 01:37:13 +02:00
|
|
|
with_items:
|
|
|
|
- "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
|
|
|
|
enabled: '{{ backup_timer_enabled | bool }}'
|
|
|
|
state: '{{ backup_timer_state }}'
|
|
|
|
become: true
|