From f398e936e4e3a6aa78db5d5ee7ebefdefbff2796 Mon Sep 17 00:00:00 2001 From: tomleb Date: Wed, 17 May 2017 18:18:03 -0400 Subject: [PATCH] Restore db and populate es from playbook --- deploy/ansible/populate_elasticsearch_index.yml | 13 +++++++++++++ deploy/ansible/restore_database.yml | 14 ++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 deploy/ansible/populate_elasticsearch_index.yml create mode 100644 deploy/ansible/restore_database.yml diff --git a/deploy/ansible/populate_elasticsearch_index.yml b/deploy/ansible/populate_elasticsearch_index.yml new file mode 100644 index 00000000..fe3720d2 --- /dev/null +++ b/deploy/ansible/populate_elasticsearch_index.yml @@ -0,0 +1,13 @@ +- name: Populate elasticsearch index from database + hosts: dbs + roles: + - common + - postgresql + - elasticsearch + + tasks: + - name: Index the database into elasticsearch + command: python "{{ nyaapantsu_directory }}/index_nyaapantsu.py" + environment: + PANTSU_DBPARAMS: "host=localhost port={{ nyaapantsu_pgpool_port }} user={{ nyaapantsu_user }} dbname={{ nyaapantsu_dbname }} sslmode=disable password={{ nyaapantsu_password }}" + PANTSU_ELASTICSEARCH_INDEX: "{{ nyaapantsu_elasticsearch_index }}" diff --git a/deploy/ansible/restore_database.yml b/deploy/ansible/restore_database.yml new file mode 100644 index 00000000..af1e96e5 --- /dev/null +++ b/deploy/ansible/restore_database.yml @@ -0,0 +1,14 @@ +- name: Restore database + hosts: dbs + roles: + - common + - postgresql + + tasks: + - name: Copy backup database + copy: + src: ../../nyaa_psql.backup + dest: "{{ nyaapantsu_directory }}" + + - name: Restore database from backup + command: pg_restore -U "{{ nyaapantsu_user }}" -d "{{ nyaapantsu_dbname }}" "{{ nyaapantsu_directory }}/nyaa_psql.backup"