Move database restoration call to separate file outside of low state
Issue: PROD-22068
Change-Id: Iea922a009737e660e35df528a08a8829163af3d0
diff --git a/xtrabackup/client.sls b/xtrabackup/client/init.sls
similarity index 69%
rename from xtrabackup/client.sls
rename to xtrabackup/client/init.sls
index 625218b..0a0f181 100644
--- a/xtrabackup/client.sls
+++ b/xtrabackup/client/init.sls
@@ -72,34 +72,4 @@
{%- endif %}
-{%- if client.restore_full_latest is defined %}
-
-xtrabackup_client_restore_script:
- file.managed:
- - name: /usr/local/bin/innobackupex-restore.sh
- - source: salt://xtrabackup/files/innobackupex-client-restore.sh
- - template: jinja
- - mode: 655
- - require:
- - pkg: xtrabackup_client_packages
-
-xtrabackup_client_call_restore_script:
- file.managed:
- - name: /usr/local/bin/innobackupex-restore-call.sh
- - source: salt://xtrabackup/files/innobackupex-client-restore-call.sh
- - template: jinja
- - mode: 655
- - require:
- - file: xtrabackup_client_restore_script
-
-xtrabackup_run_restore:
- cmd.run:
- - name: /usr/local/bin/innobackupex-restore-call.sh
- - unless: "[ -e {{ client.backup_dir }}/dbrestored ]"
- - require:
- - file: xtrabackup_client_call_restore_script
-
-{%- endif %}
-
-
{%- endif %}
diff --git a/xtrabackup/client/restore.sls b/xtrabackup/client/restore.sls
new file mode 100644
index 0000000..6f9250c
--- /dev/null
+++ b/xtrabackup/client/restore.sls
@@ -0,0 +1,32 @@
+{%- from "xtrabackup/map.jinja" import client with context %}
+{%- if client.enabled %}
+
+{%- if client.restore_full_latest is defined %}
+
+xtrabackup_client_restore_script:
+ file.managed:
+ - name: /usr/local/bin/innobackupex-restore.sh
+ - source: salt://xtrabackup/files/innobackupex-client-restore.sh
+ - template: jinja
+ - mode: 655
+
+xtrabackup_client_call_restore_script:
+ file.managed:
+ - name: /usr/local/bin/innobackupex-restore-call.sh
+ - source: salt://xtrabackup/files/innobackupex-client-restore-call.sh
+ - template: jinja
+ - mode: 655
+ - require:
+ - file: xtrabackup_client_restore_script
+
+xtrabackup_run_restore:
+ cmd.run:
+ - name: /usr/local/bin/innobackupex-restore-call.sh
+ - user: root
+ - unless: "[ -e {{ client.backup_dir }}/dbrestored ]"
+ - require:
+ - file: xtrabackup_client_call_restore_script
+
+{%- endif %}
+
+{%- endif %}