summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--playbooks/manual/staging-sync/mailman.yml92
-rwxr-xr-xscripts/public-db-copy2
2 files changed, 94 insertions, 0 deletions
diff --git a/playbooks/manual/staging-sync/mailman.yml b/playbooks/manual/staging-sync/mailman.yml
new file mode 100644
index 000000000..05563e732
--- /dev/null
+++ b/playbooks/manual/staging-sync/mailman.yml
@@ -0,0 +1,92 @@
+# This playbook syncs the production mailman instance with staging and manages all
+# the steps we need to keep our setup intact.
+
+
+- name: bring staging services down
+ hosts: mailman-stg
+ user: root
+ vars_files:
+ - /srv/web/infra/ansible/vars/global.yml
+ - "/srv/private/ansible/vars.yml"
+ - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
+ handlers:
+ - include: "{{ handlers }}/restart_services.yml"
+
+ tasks:
+ - service: name=httpd state=stopped
+ - service: name=mailman3 state=stopped
+
+
+- name: drop and re-create the staging dsb entirely
+ hosts: db01.stg.phx2.fedoraproject.org
+ user: root
+ become: yes
+ become_user: postgres
+ become_method: sudo
+
+ vars_files:
+ - /srv/web/infra/ansible/vars/global.yml
+ - "/srv/private/ansible/vars.yml"
+ - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
+ handlers:
+ - include: "{{ handlers }}/restart_services.yml"
+
+ tasks:
+ #- template: src=templates/mailman-reset-staging.sql dest=/var/lib/pgsql/mailman-reset-staging.sql
+ - copy:
+ src=/srv/web/infra/db-dumps/mailman.dump.xz
+ dest=/var/tmp/mailman.dump.xz
+ owner=postgres
+ group=postgres
+ - command: unxz /var/tmp/mailman.dump.xz
+ creates=/var/tmp/mailman.dump
+ - command: dropdb mailman
+ - command: createdb -O mailmanadmin mailman
+ - name: Import the prod db. This will take quite a while. Go get a snack!
+ command: psql -f /var/tmp/mailman.dump mailman
+ #- name: Fix the database
+ # shell: psql -f /var/lib/pgsql/mailman-reset-staging.sql mailman
+
+ #- template: src=templates/hyperkitty-reset-staging.sql dest=/var/lib/pgsql/hyperkitty-reset-staging.sql
+ - copy:
+ src=/srv/web/infra/db-dumps/hyperkitty.dump.xz
+ dest=/var/tmp/hyperkitty.dump.xz
+ owner=postgres
+ group=postgres
+ - command: unxz /var/tmp/hyperkitty.dump.xz
+ creates=/var/tmp/hyperkitty.dump
+ - command: dropdb hyperkitty
+ - command: createdb -O hyperkittyadmin hyperkitty
+ - name: Import the prod db. This will take quite a while. Go get a snack!
+ command: psql -f /var/tmp/hyperkitty.dump hyperkitty
+ #- name: Fix the database
+ # shell: psql -f /var/lib/pgsql/hyperkitty-reset-staging.sql hyperkitty
+
+ # TODO: reindex emails (fulltext)? Not a full-reindex, it may take days.
+
+
+- name: bring staging services up
+ hosts: mailman-stg
+ user: root
+ vars_files:
+ - /srv/web/infra/ansible/vars/global.yml
+ - "/srv/private/ansible/vars.yml"
+ - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
+ handlers:
+ - include: "{{ handlers }}/restart_services.yml"
+
+ tasks:
+ - service: name=httpd state=started
+ - service: name=mailman3 state=started
+
+- name: Nuke the prod db dump that we cached on batcave
+ hosts: batcave
+ user: root
+ vars_files:
+ - /srv/web/infra/ansible/vars/global.yml
+ - "/srv/private/ansible/vars.yml"
+ - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
+
+ tasks:
+ - name: Nuke the prod db dump that we cached on batcave
+ file: dest=/var/tmp/prod-mailman-dump/ state=absent
diff --git a/scripts/public-db-copy b/scripts/public-db-copy
index 699a5607d..33384a6bf 100755
--- a/scripts/public-db-copy
+++ b/scripts/public-db-copy
@@ -12,3 +12,5 @@ scp db01:/backups/koschei-$(date +%F).dump.xz /srv/web/infra/db-dumps/koschei.du
scp db01:/backups/bodhi2-$(date +%F).dump.xz /srv/web/infra/db-dumps/bodhi2.dump.xz
scp db01:/backups/pdc-$(date +%F).dump.xz /srv/web/infra/db-dumps/pdc.dump.xz
scp anitya-backend01.fedoraproject.org:/backups/anitya-$(date +%F).dump.xz /srv/web/infra/db-dumps/anitya.dump.xz
+scp db01:/backups/mailman-$(date +%F).dump.xz /srv/web/infra/db-dumps/mailman.dump.xz
+scp db01:/backups/hyperkitty-$(date +%F).dump.xz /srv/web/infra/db-dumps/hyperkitty.dump.xz