forked from BluePlanetLife/openedx-server-prep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
99-db-restore.yml
31 lines (26 loc) · 936 Bytes
/
99-db-restore.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
# Playbook to do restore
- name: Restore DB from Backup
hosts:
user:
sudo: True
gather_facts: False
vars:
timestamp: "{{ lookup('file', 'timestamp.txt') }}"
restore_dir: /tmp/restore
restore_dest: "{{ restore_dir }}/{{ timestamp }}"
restore_tar: "{{ timestamp }}.tar.gz"
local_dir: files/backups
local_path: "{{ local_dir }}/{{ restore_tar }}"
# Tasks for restore
tasks:
- name: restore folder
file: path={{ restore_dir }} state=directory
- name: upload backup
synchronize: src="{{ local_path }}" dest="{{ restore_dir }}"
- name: unpack backup
unarchive: src="{{ restore_dir }}/{{ restore_tar }}" dest="{{ restore_dir }}" copy=no
- name: restore db
shell: chdir="{{ restore_dest }}/{{ item.dir }}" {{ item.com }}
with_items:
- { com: 'mysql -u root edxapp < backup.sql', dir: 'mysql' }
- { com: 'mongorestore dump/', dir: 'mongo' }