Drop database entries only if exists
Override pg_restore pass if necessary.
PROD-34409
Change-Id: I41d163e45853586fcfdb57fc4136868d717203f6
diff --git a/maas/files/restore.sh b/maas/files/restore.sh
index ef187be..2f7f288 100644
--- a/maas/files/restore.sh
+++ b/maas/files/restore.sh
@@ -1,6 +1,7 @@
{%- from "maas/map.jinja" import region with context %}
{%- set backup_dir = pillar.get('backupninja', {}).get('client', {}).get('target', {}).get("home_dir", "/srv/backupninja") -%}
+{%- set pg_restore = pillar.get('backupninja', {}).get('client', {}).get('extra_params', {}).get("PGSQLRESTORE", "pg_restore") -%}
{%- set database = region.get("database", {}) -%}
export PGHOST={{ database.get("host", "localhost") }}
@@ -29,7 +30,7 @@
sudo systemctl stop maas-rackd.service
sudo systemctl stop maas-regiond.service
-pg_restore {{ target }}/{{ db_name }}.pg_dump --dbname={{ db_name }} --no-password -c
+{{ pg_restore }} {{ target }}/{{ db_name }}.pg_dump --dbname={{ db_name }} --no-password -c --if-exists
# Restore file permissions
if [ "$(which setfacl)" != "" ]; then