From 1da9d7731b8cda1f433bb5b33a3922716844b1bb Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Tue, 13 Dec 2022 12:55:05 -0800 Subject: config: setup cronjob for additional daily wordpress snapshot --- jinwei.me/config/roles/debian_init/tasks/main.yaml | 1 + jinwei.me/config/roles/wordpress/defaults/main.yaml | 1 + jinwei.me/config/roles/wordpress/tasks/main.yaml | 15 +++++++++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/jinwei.me/config/roles/debian_init/tasks/main.yaml b/jinwei.me/config/roles/debian_init/tasks/main.yaml index 002da90..750f83c 100644 --- a/jinwei.me/config/roles/debian_init/tasks/main.yaml +++ b/jinwei.me/config/roles/debian_init/tasks/main.yaml @@ -13,6 +13,7 @@ - mariadb-client - cifs-utils - vnstat + - postfix - lsb-release - python3 - python3-dev diff --git a/jinwei.me/config/roles/wordpress/defaults/main.yaml b/jinwei.me/config/roles/wordpress/defaults/main.yaml index 250e0a5..7eef363 100644 --- a/jinwei.me/config/roles/wordpress/defaults/main.yaml +++ b/jinwei.me/config/roles/wordpress/defaults/main.yaml @@ -2,3 +2,4 @@ wordpress_image: clarkzjw/wordpress wordpress_image_tag: 20221211 wordpress_port: 30080 wordpress_home: /opt/wordpress +samba_backup_path: /mnt/samba/VPS/aws-jinwei-me/wordpress/ diff --git a/jinwei.me/config/roles/wordpress/tasks/main.yaml b/jinwei.me/config/roles/wordpress/tasks/main.yaml index 3835145..128a3e9 100644 --- a/jinwei.me/config/roles/wordpress/tasks/main.yaml +++ b/jinwei.me/config/roles/wordpress/tasks/main.yaml @@ -1,4 +1,4 @@ -- name: Pull wordpress Docker image +- name: pull wordpress Docker image community.docker.docker_image: name: "{{ wordpress_image }}:{{ wordpress_image_tag }}" source: pull @@ -9,8 +9,19 @@ dest: "{{ wordpress_home }}/docker-compose.yaml" mode: 0644 -- name: Start wordpress container using docker-compose +- name: start wordpress container using docker-compose community.docker.docker_compose: project_name: wordpress project_src: "{{ wordpress_home }}" register: output + +- name: setup cronjob for additional backup + cron: + cron_file: wordpress_backup_hetzner + user: root + state: present + name: "wordpress backup" + minute: "0" + hour: "0" + day: "*" + job: "tar caf /tmp/wordpress-$(date -u +\\%Y-\\%m-\\%d-\\%H-\\%M-\\%S\\%Z).tar.xz {{ wordpress_home }} && rsync -azvP /tmp/wordpress-*.tar.xz {{ samba_backup_path }}" -- cgit v1.2.3