decorrelation SITE et sous domain
[lhc/ansible.git] / tasks / backup_nextcloud.yml
diff --git a/tasks/backup_nextcloud.yml b/tasks/backup_nextcloud.yml
new file mode 100644 (file)
index 0000000..f985f82
--- /dev/null
@@ -0,0 +1,30 @@
+- name: Active le mode maintenance  # noqa : command-instead-of-module
+  become_user: "{{ nextcloud_php_user }}"
+  become: true
+  ansible.builtin.command: './console maintenance:mode --on'
+  args:
+    chdir: "{{ nextcloud_webroot }}"
+
+- name: Create a dump of the postgreSQL database # noqa : command-instead-of-module
+  become: true
+  become_user: "{{ nextcloud_php_user }}"
+  ansible.builtin.command: "pg_dump -f /tmp/dump.pgc -F c -O -b {{ nextcloud_db_name }}"
+  args:
+    chdir: "{{ nextcloud_webroot }}"
+
+- name: Copy nextcloud config file
+  become: true
+  ansible.builtin.copy:
+    src: "{{ nextcloud_webroot }}/config/config.php"
+    dest: "{{ nextcloud_webroot }}/config/config.php.bak"
+    remote_src: true # because the src is already on the remote host
+    owner: "{{ nextcloud_php_user }}"
+    group: "{{ nextcloud_websrv_user }}"
+    mode: '640'
+
+- name: Desactive le mode maintenance # noqa : command-instead-of-module
+  become_user: "{{ nextcloud_php_user }}"
+  become: true
+  ansible.builtin.command: './console maintenance:mode --off'
+  args:
+    chdir: "{{ nextcloud_webroot }}"
\ No newline at end of file