added backup and backup rotation to wordpress

This commit is contained in:
Adrien Luxey 2020-05-03 18:35:42 +02:00
parent 812ae572d8
commit 12ff2735a1
2 changed files with 51 additions and 18 deletions

View file

@ -5,6 +5,7 @@ adrien_serenity_password: "{{ vault_adrien_serenity_password }}"
www_path: /vault/www www_path: /vault/www
sites_path: /vault/sites sites_path: /vault/sites
backups_path: /vault/backups
wordpress: wordpress:
version: 5.4 version: 5.4
@ -101,21 +102,21 @@ sites:
mysql_username: lexperimental mysql_username: lexperimental
mysql_password: "{{ vault_lexperimental_mysql_password }}" mysql_password: "{{ vault_lexperimental_mysql_password }}"
# - slug: mts # Shorthand name to use as directory/file name - slug: mts # Shorthand name to use as directory/file name
# # The site URL (without www) # The site URL (without www)
# url: editionsmangetasoupe.fr url: editionsmangetasoupe.fr
# # Ask nginx to redirect url to www # Ask nginx to redirect url to www
# # Else, we redirect www to url # Else, we redirect www to url
# redirect_to_www: no redirect_to_www: no
# # What kind of site is that? # What kind of site is that?
# type: drupal type: drupal
# # Subnet addresses # Subnet addresses
# subnet_cidr_address: 172.27.5.0/24 subnet_cidr_address: 172.27.5.0/24
# subnet_gateway_ip: 172.27.5.1 subnet_gateway_ip: 172.27.5.1
# subnet_site_ip: 172.27.5.2 subnet_site_ip: 172.27.5.2
# # This will allow setting up MySQL # This will allow setting up MySQL
# # Configuration on Drupal's side must be done by hand: # Configuration on Drupal's side must be done by hand:
# # Edit your <drupal_install>/sites/default/settings.php # Edit your <drupal_install>/sites/default/settings.php
# mysql_database: mts8 mysql_database: mts8
# mysql_username: mts mysql_username: mts
# mysql_password: "{{ vault_mts_mysql_password }}" mysql_password: "{{ vault_mts_mysql_password }}"

View file

@ -52,6 +52,38 @@
when: wpcontent.stat.exists is not defined or wpcontent.stat.exists == False when: wpcontent.stat.exists is not defined or wpcontent.stat.exists == False
tags: [docker, nginx] tags: [docker, nginx]
#################
# Setup backups #
#################
- name: Setup weekly backup of wp-content
cron:
name: "backup {{ item.slug }}_wp-content"
# hour: "17"
# minute: "37"
special_time: weekly
user: "www-data"
job: "tar czf {{ backups_path }}/{{ item.slug }}_wp-content.tar.gz {{ www_path }}/{{ item.slug }}_wp-content"
become: yes
tags: backup
- name: Configure logrotate to rotate backups
blockinfile:
path: "/etc/logrotate.d/{{ item.slug }}"
create: yes
block: |
{{ backups_path }}/{{ item.slug }}_wp-content.tar.gz {
rotate 5
nocompress
dateext
dateformat _%Y-%m-%d
extension .tar.gz
missingok
}
become: yes
tags: backup
#################### ####################
# Render templates # # Render templates #
#################### ####################