Skip to content

Commit

Permalink
Add filtering db items using itemsfile_filter and exclude spatial_ref…
Browse files Browse the repository at this point in the history
…_sys from export
  • Loading branch information
fdemmer committed May 29, 2018
1 parent 886c132 commit f076c4b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions django/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,4 @@ remote_tempfile: "{{ tempfile }}"
local_tempfile: "{{ tempfile }}"
target_tempfile: "{{ tempfile }}"
target_itemsfile: "{{ tempfile }}.items"
itemsfile_filter: []
13 changes: 12 additions & 1 deletion django/tasks/90-commands/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- name: create new database dump
become: no
#local_action: shell ssh {{ live_db_host }} "pg_dump -F t -O -U {{ live_db_user }} {{ live_db_name }} | gzip -c > {{ remote_tempfile }}"
local_action: shell ssh -o StrictHostKeyChecking=no {{ live_host_user }}@{{ live_db_host }} "pg_dump -Fc -f {{ remote_tempfile }} --no-owner --no-acl -U {{ live_db_user }} {{ live_db_name }}"
local_action: shell ssh -o StrictHostKeyChecking=no {{ live_host_user }}@{{ live_db_host }} "pg_dump -Fc -f {{ remote_tempfile }} --no-owner --no-acl -T 'spatial_ref_sys' -U {{ live_db_user }} {{ live_db_name }}"
tags:
- create_dump
- import_database
Expand Down Expand Up @@ -40,6 +40,17 @@
- restore_dump
- import_database

- name: filter itemsfile
become: no
lineinfile:
path: "{{ target_itemsfile }}"
state: absent
regexp: "{{ item }}"
with_items: "{{ itemsfile_filter }}"
tags:
- restore_dump
- import_database

- name: restore database dump
become: no
command: pg_restore -O -h {{ db_host }} -U {{ db_user }} -d {{ db_name }} -L {{ target_itemsfile }} {{ target_tempfile }}
Expand Down

0 comments on commit f076c4b

Please sign in to comment.