Sélectionner une révision Git
restore-odootest.yaml.j2

Rémi - Le Filament authored
restore-odootest.yaml.j2 2,91 Kio
version: "2.1"
services:
restore_test:
image: tecnativa/duplicity:postgres
hostname: {{ inventory_hostname_short | lower | regex_replace('_','') }}-odoo
networks:
- {{ item.dir }}_default
- public
environment:
PGDATABASE: "{{ item.db }}"
SWIFT_USERNAME: "{{ swift_odoo_username }}"
SWIFT_PASSWORD: "{{ swift_odoo_password }}"
SWIFT_AUTHURL: "{{ swift_odoo_authurl }}"
SWIFT_AUTHVERSION: {{ swift_odoo_authversion }}
SWIFT_TENANTNAME: "{{ swift_odoo_tenantname }}"
SWIFT_TENANTID: "{{ swift_odoo_tenantid }}"
SWIFT_REGIONNAME: "{{ swift_odoo_regionname }}"
OPTIONS: "--force --allow-source-mismatch"
{% if odoo_prod is defined %}
DST: "swift://odoo_{{ inventory_hostname|lower }}"
PGUSER: "{{ odoo_prod.db_user }}"
PGPASSWORD: "{{ odoo_prod.db_pass }}"
PASSPHRASE: "{{ odoo_backup_pass | default(odoo_prod.master_pass) }}"
volumes:
- backups_odoo_backup_cache:/root/.cache/duplicity/:z
- {{ item.dir }}_filestore:/mnt/backup/src/odoo:z
- ./post_restore-{{ item.name }}.sql:/tmp/post-restore.sql:ro
- ./pre_restore-{{ item.name }}.sql:/tmp/pre-restore.sql:ro
command: [sh, -c, "psql -a -f /tmp/pre-restore.sql postgres ; echo 'remove existing dir' && rm -rf /mnt/backup/src/odoo/filestore/$$PGDATABASE && restore && echo 'move repo to final dest' && mv /mnt/backup/src/odoo/filestore/{{ odoo_prod.db }} /mnt/backup/src/odoo/filestore/$$PGDATABASE && echo 'create database' && createdb -T template0 $$PGDATABASE && echo 'restore database' && pg_restore -d $$PGDATABASE $$SRC/{{ odoo_prod.db }}.pgdump ; psql -a -f /tmp/post-restore.sql $$PGDATABASE"]
{% else %}
DST: "swift://odoo_{{ item.prod_inv_name|lower }}"
PGUSER: "{{ item.db_user }}"
PGPASSWORD: "{{ item.db_pass }}"
PASSPHRASE: "{{ hostvars[item.prod_inv_name].odoo_backup_pass | default(hostvars[item.prod_inv_name].odoo_prod.master_pass) }}"
command: [sh, -c, "psql -a -f /tmp/pre-restore.sql postgres ; echo 'remove existing dir' && rm -rf /mnt/backup/src/odoo/filestore/$$PGDATABASE && restore && echo 'move repo to final dest' && mv /mnt/backup/src/odoo/filestore/{{ hostvars[item.prod_inv_name].odoo_prod.db }} /mnt/backup/src/odoo/filestore/$$PGDATABASE && echo 'create database' && createdb -T template0 $$PGDATABASE && echo 'restore database' && pg_restore -d $$PGDATABASE $$SRC/{{ hostvars[item.prod_inv_name].odoo_prod.db }}.pgdump ; psql -a -f /tmp/post-restore.sql $$PGDATABASE"]
{% endif %}
networks:
{{ item.dir }}_default:
external: true
public:
driver_opts:
encrypted: 1
volumes:
backups_odoo_backup_cache:
{% if odoo_prod is defined %}
external: true
{% endif %}
{{ item.dir }}_filestore:
external: true