Initial Commit

This commit is contained in:
Antoine VILLETTE
2020-03-24 16:50:04 +01:00
parent e1321567d9
commit 4be3b60afa
2 changed files with 23 additions and 0 deletions

21
copy_all_users.yml Normal file
View File

@@ -0,0 +1,21 @@
---
- name: Copy user database from a one nextcloud to another
hosts: all
vars:
container_name: "db"
tasks:
- debug: msg="{{ nextcloud_admin_passwd }}"
- name: Backup Postgres necessary table on src
block:
- shell: "docker exec -u postgres {{ container_name }} pg_dump --clean -t public.oc_accounts -t public.oc_users -t public.oc_groups -t public.oc_group_admin -t public.oc_group_user nextcloud > /tmp/nextcloud_backup.sql"
- name: Fetch the SQL dump from src
run_once: yes
fetch: src=/tmp/nextcloud_backup.sql dest=/tmp/ flat=yes
when: inventory_hostname == "nextcloud-src"
- name: Restore Postgres necessary table on dst
block:
- name: Copy the SQL dump to dst
copy: src=/tmp/nextcloud_backup.sql dest=//tmp/
become: yes
- shell: "docker exec -i -u postgres {{ container_name }} psql nextcloud < /tmp/nextcloud_backup.sql"
when: inventory_hostname == "nextcloud-dst"