new version
Some checks failed
Some checks failed
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
---
|
||||
- name: Create backup directories
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
owner: "{{ minecraft_user }}"
|
||||
group: "{{ minecraft_group }}"
|
||||
mode: '0755'
|
||||
loop: "{{ backup_dirs }}"
|
12
roles/04-backups/tasks/01-create-backup-structure.yml
Normal file
12
roles/04-backups/tasks/01-create-backup-structure.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
- name: Création de la structure des sauvegardes
|
||||
ansible.builtin.file:
|
||||
path: "{{ minecraft_backups_dir }}/{{ item }}"
|
||||
state: directory
|
||||
owner: "{{ minecraft_user }}"
|
||||
group: "{{ minecraft_group }}"
|
||||
mode: '0755'
|
||||
with_items:
|
||||
- daily
|
||||
- weekly
|
||||
- monthly
|
@@ -1,6 +0,0 @@
|
||||
---
|
||||
- name: Install rsync
|
||||
ansible.builtin.apt:
|
||||
name: rsync
|
||||
state: present
|
||||
when: ansible_os_family == "Debian"
|
17
roles/04-backups/tasks/02-setup-daily-backup.yml
Normal file
17
roles/04-backups/tasks/02-setup-daily-backup.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
---
|
||||
- name: Création du script de sauvegarde quotidienne
|
||||
ansible.builtin.template:
|
||||
src: backup-daily.sh.j2
|
||||
dest: "{{ backup_script_path }}/minecraft-backup-daily.sh"
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0755'
|
||||
|
||||
- name: Configuration cron pour sauvegarde quotidienne
|
||||
ansible.builtin.cron:
|
||||
name: "Minecraft Daily Backup"
|
||||
minute: "0"
|
||||
hour: "2"
|
||||
job: "{{ backup_script_path }}/minecraft-backup-daily.sh"
|
||||
user: "{{ minecraft_user }}"
|
||||
state: present
|
@@ -1,16 +0,0 @@
|
||||
---
|
||||
- name: Create backup script
|
||||
ansible.builtin.template:
|
||||
src: backup.sh.j2
|
||||
dest: "{{ minecraft_base_dir }}/backup.sh"
|
||||
owner: "{{ minecraft_user }}"
|
||||
group: "{{ minecraft_group }}"
|
||||
mode: '0755'
|
||||
|
||||
- name: Create restore script
|
||||
ansible.builtin.template:
|
||||
src: restore.sh.j2
|
||||
dest: "{{ minecraft_base_dir }}/restore.sh"
|
||||
owner: "{{ minecraft_user }}"
|
||||
group: "{{ minecraft_group }}"
|
||||
mode: '0755'
|
18
roles/04-backups/tasks/03-setup-weekly-backup.yml
Normal file
18
roles/04-backups/tasks/03-setup-weekly-backup.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
- name: Création du script de sauvegarde hebdomadaire
|
||||
ansible.builtin.template:
|
||||
src: backup-weekly.sh.j2
|
||||
dest: "{{ backup_script_path }}/minecraft-backup-weekly.sh"
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0755'
|
||||
|
||||
- name: Configuration cron pour sauvegarde hebdomadaire
|
||||
ansible.builtin.cron:
|
||||
name: "Minecraft Weekly Backup"
|
||||
minute: "0"
|
||||
hour: "3"
|
||||
weekday: "0"
|
||||
job: "{{ backup_script_path }}/minecraft-backup-weekly.sh"
|
||||
user: "{{ minecraft_user }}"
|
||||
state: present
|
@@ -1,29 +0,0 @@
|
||||
---
|
||||
- name: Setup daily backup cron job
|
||||
ansible.builtin.cron:
|
||||
name: "Minecraft daily backup"
|
||||
user: "{{ minecraft_user }}"
|
||||
hour: "{{ backup_time_daily.split(':')[0] }}"
|
||||
minute: "{{ backup_time_daily.split(':')[1] }}"
|
||||
job: "{{ minecraft_base_dir }}/backup.sh daily"
|
||||
notify: reload cron service
|
||||
|
||||
- name: Setup weekly backup cron job
|
||||
ansible.builtin.cron:
|
||||
name: "Minecraft weekly backup"
|
||||
user: "{{ minecraft_user }}"
|
||||
hour: "{{ backup_time_weekly.split(':')[0] }}"
|
||||
minute: "{{ backup_time_weekly.split(':')[1] }}"
|
||||
weekday: "0"
|
||||
job: "{{ minecraft_base_dir }}/backup.sh weekly"
|
||||
notify: reload cron service
|
||||
|
||||
- name: Setup monthly backup cron job
|
||||
ansible.builtin.cron:
|
||||
name: "Minecraft monthly backup"
|
||||
user: "{{ minecraft_user }}"
|
||||
hour: "{{ backup_time_monthly.split(':')[0] }}"
|
||||
minute: "{{ backup_time_monthly.split(':')[1] }}"
|
||||
day: "1"
|
||||
job: "{{ minecraft_base_dir }}/backup.sh monthly"
|
||||
notify: reload cron service
|
18
roles/04-backups/tasks/04-setup-monthly-backup.yml
Normal file
18
roles/04-backups/tasks/04-setup-monthly-backup.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
- name: Création du script de sauvegarde mensuelle
|
||||
ansible.builtin.template:
|
||||
src: backup-monthly.sh.j2
|
||||
dest: "{{ backup_script_path }}/minecraft-backup-monthly.sh"
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0755'
|
||||
|
||||
- name: Configuration cron pour sauvegarde mensuelle
|
||||
ansible.builtin.cron:
|
||||
name: "Minecraft Monthly Backup"
|
||||
minute: "0"
|
||||
hour: "4"
|
||||
day: "1"
|
||||
job: "{{ backup_script_path }}/minecraft-backup-monthly.sh"
|
||||
user: "{{ minecraft_user }}"
|
||||
state: present
|
@@ -1,26 +0,0 @@
|
||||
---
|
||||
- name: Create restore script
|
||||
ansible.builtin.template:
|
||||
src: restore.sh.j2
|
||||
dest: "{{ minecraft_base_dir }}/restore.sh"
|
||||
owner: "{{ minecraft_user }}"
|
||||
group: "{{ minecraft_group }}"
|
||||
mode: '0755'
|
||||
|
||||
- name: Stop minecraft server before restore
|
||||
ansible.builtin.systemd:
|
||||
name: "{{ minecraft_service_name }}"
|
||||
state: stopped
|
||||
when: restore_backup_type is defined
|
||||
|
||||
- name: Execute restore
|
||||
ansible.builtin.command:
|
||||
cmd: "{{ minecraft_base_dir }}/restore.sh {{ restore_backup_type }} {{ restore_backup_date | default('latest') }}"
|
||||
become_user: "{{ minecraft_user }}"
|
||||
when: restore_backup_type is defined
|
||||
|
||||
- name: Start minecraft server after restore
|
||||
ansible.builtin.systemd:
|
||||
name: "{{ minecraft_service_name }}"
|
||||
state: started
|
||||
when: restore_backup_type is defined
|
8
roles/04-backups/tasks/05-setup-restore-script.yml
Normal file
8
roles/04-backups/tasks/05-setup-restore-script.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
- name: Création du script de restauration
|
||||
ansible.builtin.template:
|
||||
src: restore.sh.j2
|
||||
dest: "{{ backup_script_path }}/minecraft-restore.sh"
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0755'
|
@@ -1,16 +1,16 @@
|
||||
---
|
||||
- name: Include create backup directories tasks
|
||||
ansible.builtin.include_tasks: 01-create-backup-dirs.yml
|
||||
# Tâches principales sauvegardes
|
||||
- import_tasks: 01-create-backup-structure.yml
|
||||
tags: [backup, structure]
|
||||
|
||||
- name: Include install rsync tasks
|
||||
ansible.builtin.include_tasks: 02-install-rsync.yml
|
||||
- import_tasks: 02-setup-daily-backup.yml
|
||||
tags: [backup, daily]
|
||||
|
||||
- name: Include configure backup script tasks
|
||||
ansible.builtin.include_tasks: 03-configure-backup-script.yml
|
||||
- import_tasks: 03-setup-weekly-backup.yml
|
||||
tags: [backup, weekly]
|
||||
|
||||
- name: Include setup cron tasks
|
||||
ansible.builtin.include_tasks: 04-setup-cron.yml
|
||||
- import_tasks: 04-setup-monthly-backup.yml
|
||||
tags: [backup, monthly]
|
||||
|
||||
- name: Include restore backup tasks
|
||||
ansible.builtin.include_tasks: 05-restore-backup.yml
|
||||
when: restore_backup | default(false)
|
||||
- import_tasks: 05-setup-restore-script.yml
|
||||
tags: [backup, restore]
|
Reference in New Issue
Block a user