From eec548f5c145f5dab7135cb2df19ec18a7dda15b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 21 Dec 2024 05:38:50 +0200 Subject: [PATCH] Tasks Update: Adding Backup tasks --- tasks.yml | 8 ++++++++ tasks/backup.yml | 19 +++++++++++++++++++ tasks/installer.yml | 9 +++++++++ 3 files changed, 36 insertions(+) create mode 100644 tasks/backup.yml diff --git a/tasks.yml b/tasks.yml index c7306ce..6be3e85 100644 --- a/tasks.yml +++ b/tasks.yml @@ -29,3 +29,11 @@ tags: - deployer - never + + - name: "Backup" + import_tasks: tasks/backup.yml + vars: + ansible_python_interpreter: "{{ ansible_facts.user_dir }}/.venv/ansible/bin/python3" + tags: + - backup + - never diff --git a/tasks/backup.yml b/tasks/backup.yml new file mode 100644 index 0000000..c15f400 --- /dev/null +++ b/tasks/backup.yml @@ -0,0 +1,19 @@ +--- +- name: "Backup - Minecraft - Stop" + containers.podman.podman_container: + name: minecraft + state: stopped + +- name: "Backup - Minecraft - Save" + community.general.archive: + path: + - "~/data/minecraft" + exclude_path: + - "~/data/minecraft/plugins/dynmap/web/tiles" + dest: "~/data/backups/minecraft-{{ ansible_facts.date_time.date }}.zip" + format: zip + +- name: "Backup - Minecraft - Start" + containers.podman.podman_container: + name: minecraft + state: started diff --git a/tasks/installer.yml b/tasks/installer.yml index 3220e7d..dad4dee 100644 --- a/tasks/installer.yml +++ b/tasks/installer.yml @@ -119,3 +119,12 @@ job: "~/.venv/ansible/bin/ansible-pull -U ssh://git@github.com/MatteZ02/infra -d ~/.ansible/pull/matte/infra --accept-host-key --private-key ~/.ssh/keys/matte/infra --vault-password-file ~/.ansible/vault/matte.yml tasks.yml -t deployer" tags: - cron + +- name: "Installer : Schedule : Backup" + cron: + name: "Matte - Infra - Backup" + hour: "5" + minute: "0" + job: "~/.venv/ansible/bin/ansible-pull -U ssh://git@github.com/MatteZ02/infra -d ~/.ansible/pull/matte/infra --accept-host-key --private-key ~/.ssh/keys/matte/infra --vault-password-file ~/.ansible/vault/matte.yml tasks.yml -t backup" + tags: + - cron