-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathims-dump.yml
92 lines (85 loc) · 2.7 KB
/
ims-dump.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
- name: Dump the database to localhost
hosts: ebisc-ims-fh
tags: database
vars:
postgresql_database: ims
postgresql_user: ims
postgresql_password: "{{ vault_postgresql_password }}"
pre_tasks:
- name: include vault vars
include_vars: ims_vault.yml
tasks:
- name: Create a temp directory
file:
path: /tmp/db_dump
state: directory
mode: "0777"
- name: Dump the current database
environment:
PGPASSWORD: "{{ postgresql_password }}"
PGUSER: "{{ postgresql_user }}"
PGDATABASE: "{{ postgresql_database }}"
command: "{{ item }}"
with_items:
- /var/projects/ebisc/scripts/dump_db.bash
- /var/projects/ebisc/scripts/export_db.bash celllines_cellline cellline.csv
- /var/projects/ebisc/scripts/export_db.bash celllines_celllinebatch batch.csv
- /var/projects/ebisc/scripts/export_db.bash celllines_celllinebatchimages batchimages.csv
- /var/projects/ebisc/scripts/export_db.bash celllines_batchcultureconditions batchculture.csv
- /var/projects/ebisc/scripts/export_db.bash celllines_celllinealiquot vial.csv
- /var/projects/ebisc/scripts/export_db.bash celllines_celllineinformationpack clip.csv
- /var/projects/ebisc/scripts/export_db.bash celllines_celllinestatus status.csv
- /var/projects/ebisc/scripts/export_db.bash auth_user user.csv
- name: Create backup directories
file:
path: "{{ item }}"
state: directory
delegate_to: localhost
with_items:
- "{{ playbook_dir }}/backup"
- "{{ playbook_dir }}/backup/sql"
- "{{ playbook_dir }}/backup/csv"
- name: fetch the backup
fetch:
dest: "{{ playbook_dir }}/backup/{{ item.dir }}/"
fail_on_missing: yes
src: "/tmp/db_dump/{{ item.src }}"
flat: yes
with_items:
- src: ebisc.sql.gz
dir: sql
- src: cellline.csv
dir: csv
- src: batch.csv
dir: csv
- src: batchimages.csv
dir: csv
- src: batchculture.csv
dir: csv
- src: vial.csv
dir: csv
- src: clip.csv
dir: csv
- src: status.csv
dir: csv
- src: user.csv
dir: csv
- name: delete the remote backup
become: yes
file:
path: /tmp/db_dump
state: absent
- name: Dump the media files to localhost
hosts: ebisc-ims-fh
tags: media
vars:
data_dir: /data01
tasks:
- name: synchronize media files
become: yes
synchronize:
src: "{{ data_dir }}/media"
dest: "{{ playbook_dir }}/backup/"
delete: yes
use_ssh_args: yes
mode: pull