Add backups für strato production server.
This commit is contained in:
64
strato-production.yaml
Normal file
64
strato-production.yaml
Normal file
@@ -0,0 +1,64 @@
|
||||
---
|
||||
# This playbook backups the odroid docker containers.
|
||||
- name: Backup Strato Production
|
||||
hosts: all
|
||||
gather_facts: true
|
||||
|
||||
tasks:
|
||||
- name: Backup odroid
|
||||
block:
|
||||
- include_vars: vars/mattermost.yaml
|
||||
- include_vars: vars/strato-production.yaml
|
||||
|
||||
- name: Check if directories exist
|
||||
stat:
|
||||
path: "{{ backup_dir }}/{{ item }}"
|
||||
register: dirs
|
||||
loop: "{{ systems }}"
|
||||
|
||||
- name: Create not existing directories
|
||||
file:
|
||||
path: "{{ backup_dir }}/{{ item.item }}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
group: chris
|
||||
owner: chris
|
||||
when: item.stat.exists == false
|
||||
with_items: "{{ dirs.results }}"
|
||||
loop_control:
|
||||
label: "{{ item.item }}"
|
||||
|
||||
- name: Backup mysql databases
|
||||
shell: docker exec {{ item }}-db mysqldump -u{{ item }} -p{{ lookup('vars', item ~ '-password') }} {{ item }} > {{ backup_dir }}/{{ item }}/db-{{ ansible_date_time.iso8601_basic_short }}.sql
|
||||
loop: "{{ mysql_databases }}"
|
||||
|
||||
- name: Compress database backup files
|
||||
shell: gzip {{ backup_dir }}/{{ item }}/db-{{ ansible_date_time.iso8601_basic_short }}.sql
|
||||
loop: "{{ databases }}"
|
||||
|
||||
- name: Inform Mattermost about success
|
||||
uri:
|
||||
url: "{{ mattermost_url }}"
|
||||
method: POST
|
||||
body_format: json
|
||||
body:
|
||||
channel_id: "{{ channel_id }}"
|
||||
message: "{{ ansible_date_time.date }} {{ ansible_date_time.time }}: Playbook ran successful ({{ ansible_play_name }})"
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
Authorization: "Bearer {{ semaphore_token }}"
|
||||
status_code: [200, 201]
|
||||
|
||||
rescue:
|
||||
- name: Inform Mattermost about error
|
||||
uri:
|
||||
url: "{{ mattermost_url }}"
|
||||
method: POST
|
||||
body_format: json
|
||||
body:
|
||||
channel_id: "{{ channel_id }}"
|
||||
message: "{{ ansible_date_time.date }} {{ ansible_date_time.time }}: Playbook ran with error ({{ ansible_play_name }})"
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
Authorization: "Bearer {{ error_token }}"
|
||||
status_code: [200, 201]
|
||||
32
vars/strato-production.yaml
Normal file
32
vars/strato-production.yaml
Normal file
@@ -0,0 +1,32 @@
|
||||
backup_dir: /media/backup/strato-production
|
||||
systems: ['buehler', 'scheidle', 'mailserver', 'roundcube', 'svj']
|
||||
databases: ['buehler', 'scheidle', 'roundcube', 'svj']
|
||||
mysql_databases: ['buehler', 'scheidle', 'roundcube', 'svj']
|
||||
buehler-password: !vault |
|
||||
$ANSIBLE_VAULT;1.1;AES256
|
||||
37306230376433313631326230313739396238666239323362366164363831643664306535346464
|
||||
3161643933633336366364636534333662383731376633300a303666373565356564323361346636
|
||||
63366162336662636266613235643335323835613838663839383433656362366566336637353938
|
||||
3961633364303334330a363136373931396536623836303833666431393932316636396432346232
|
||||
66643031663162373838333434616462333465316134626238306334633439643734336561396531
|
||||
6531316263333335626662656139303235313137666162326138
|
||||
scheidle-password: !vault |
|
||||
$ANSIBLE_VAULT;1.1;AES256
|
||||
30346162333562373233306562626135306530343334663938653661653063363839666266313833
|
||||
6538373639643435663032323939613464333931623933610a303334316633646164356161313865
|
||||
65353662346263353537343136663738316132323537663761636535613563336439653935333365
|
||||
3333373666353232640a323938343030366233326232393164396264343831313834326436336630
|
||||
62623137363631346263343633663236646537643065353932396334613935633736
|
||||
roundcube-password: !vault |
|
||||
$ANSIBLE_VAULT;1.1;AES256
|
||||
63626165346530336461393438333731316132366666643334616537323638373362373835656436
|
||||
6136636561306438323762386663393863303533373464630a346639366539393936646334643732
|
||||
38383465636536646533363035366335326261323235353664643136393531306464333633636538
|
||||
3138656666643039610a663663303065313538373865343235313963353865313861323231663631
|
||||
66656435636263626633356636306636303434323265346333366630383531313637svj-password: !vault |
|
||||
$ANSIBLE_VAULT;1.1;AES256
|
||||
64386230373266663734633264613839623135323335313934373264393764353338323430313131
|
||||
3131616663616461306366373138626439363064616237380a613465663335373063663830656638
|
||||
31316433653265313733393862653634666261643865363364323165326139323230633838366339
|
||||
3731613934383064310a666338373530633136336362646139373633323139333738363061393562
|
||||
38653231333437653066346465633635336663643137363431326239333135616230
|
||||
Reference in New Issue
Block a user