mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-05-08 06:13:21 +00:00
There is a new backup role in the roles folder:
roles/ipabackup
This role allows to backup an IPA server, to copy a backup from the
server to the controller, to copy all backups from the server to the
controller, to remove a backup from the server, to remove all backups
from the server, to restore an IPA server locally and from the controller
and also to copy a backup from the controller to the server.
Here is the documentation for the role:
roles/ipabackup/README.md
New example playbooks have been added:
playbooks/backup-server.yml
playbooks/backup-server-to-controller.yml
playbooks/copy-backup-from-server.yml
playbooks/copy-all-backups-from-server.yml
playbooks/remove-backup-from-server.yml
playbooks/remove-all-backups-from-server.yml
playbooks/copy-backup-to-server.yml
playbooks/restore-server-from-controller.yml
playbooks/restore-server.yml
44 lines
1.3 KiB
YAML
44 lines
1.3 KiB
YAML
---
|
|
- name: Fail on invalid ipabackup_name
|
|
fail: msg="ipabackup_name {{ ipabackup_name }} is not valid"
|
|
when: ipabackup_name is not defined or
|
|
ipabackup_name | length < 1 or
|
|
(ipabackup_name.find("ipa-full-") == -1 and
|
|
ipabackup_name.find("ipa-data-") == -1)
|
|
|
|
- name: Set controller source directory
|
|
set_fact:
|
|
ipabackup_controller_dir:
|
|
"{{ ipabackup_controller_path | default(lookup('env','PWD')) }}"
|
|
|
|
- name: Set ipabackup_item
|
|
set_fact:
|
|
ipabackup_item:
|
|
"{{ ipabackup_name | regex_search('.*_(ipa-.+)','\\1') | first }}"
|
|
when: "'_ipa-' in ipabackup_name"
|
|
|
|
- name: Set ipabackup_item
|
|
set_fact:
|
|
ipabackup_item: "{{ ipabackup_name }}"
|
|
when: "'_ipa-' not in ipabackup_name"
|
|
|
|
- name: Stat backup to copy
|
|
stat:
|
|
path: "{{ ipabackup_controller_dir }}/{{ ipabackup_name }}"
|
|
register: result_backup_stat
|
|
delegate_to: localhost
|
|
become: no
|
|
|
|
- name: Fail on missing backup to copy
|
|
fail: msg="Unable to find backup {{ ipabackup_name }}"
|
|
when: result_backup_stat.stat.isdir is not defined
|
|
|
|
- name: Copy backup files to server for "{{ ipabackup_item }}"
|
|
copy:
|
|
src: "{{ ipabackup_controller_dir }}/{{ ipabackup_name }}/"
|
|
dest: "{{ ipabackup_dir }}/{{ ipabackup_item }}"
|
|
owner: root
|
|
group: root
|
|
mode: u=rw,go=r
|
|
directory_mode: u=rwx,go=
|