borgbackup.yml ※各パラメータは適宜変更してください。
---
- hosts: borgbackup
vars:
borgbackup_repository: /opt/repo
borgbackup_encryption_key: repokey
borgbackup_passphrase: mypassphrase
borgbackup_target: /home/vagrant/playbook
roles:
- borgbackup
role/borgbackup/tasks/main.yml
---
- name: install borgbackup
apt: name=borgbackup state=present update_cache=yes
become: true
- name: create repository directroy
file: path={{ borgbackup_repository }} state=directory owner={{ ansible_user }}
become: true
- name: check data directory in the repo
stat:
path: "{{ borgbackup_repository }}/data"
register: chk_data
- name: initialize repository
shell: borg init -e {{ borgbackup_encryption_key }} {{ borgbackup_repository }}
environment:
BORG_PASSPHRASE: "{{ borgbackup_passphrase }}"
when: chk_data.stat.exists == false
- name: take initial backup
shell: borg create --stats "{{ borgbackup_repository }}::init" {{ borgbackup_target }}
environment:
BORG_PASSPHRASE: "{{ borgbackup_passphrase }}"
when: chk_data.stat.exists == false
- name: show result of initial backup...
shell: borg list "{{ borgbackup_repository }}::init"
register: cmd_output
environment:
BORG_PASSPHRASE: "{{ borgbackup_passphrase }}"
changed_when: false
- name: output the result
debug:
msg: "{{ cmd_output }}"
〇動作環境
・Ubuntu 18.04
0 件のコメント:
コメントを投稿