59 lines
1.4 KiB
YAML
59 lines
1.4 KiB
YAML
---
|
|
# This playbook creates a backup of minisforum and writes it to odroid.
|
|
- name: Backup minisforum to odroid
|
|
hosts: all
|
|
vars:
|
|
directories:
|
|
- docker
|
|
- media
|
|
- nextcloud
|
|
- sftp
|
|
- strato-production
|
|
gather_facts: false
|
|
|
|
tasks:
|
|
- name: Wakeup odroid
|
|
community.general.wakeonlan:
|
|
mac: '00:1E:06:45:4C:45'
|
|
delegate_to: localhost
|
|
|
|
- name: Wait odroid is responding
|
|
ansible.builtin.wait_for_connection:
|
|
|
|
- name: Gathering facts
|
|
ansible.builtin.setup:
|
|
|
|
- name: Mount minisforum storage
|
|
ansible.posix.mount:
|
|
src: 192.168.178.46:/
|
|
path: /media/nas
|
|
state: mounted
|
|
fstype: nfs
|
|
become: true
|
|
|
|
- name: Check backup directory exists
|
|
ansible.builtin.file:
|
|
path: /media/backup/minisforum
|
|
state: directory
|
|
mode: '0755'
|
|
|
|
- name: Check file path for storage directories exists
|
|
ansible.builtin.file:
|
|
path: /media/backup/minisforum/{{ item }}
|
|
state: directory
|
|
mode: '0755'
|
|
loop: "{{ directories }}"
|
|
|
|
- name: Backup minisforum directories
|
|
ansible.builtin.shell: rsync -a --delete /media/nas/{{ item }}/ /media/backup/minisforum/{{ item }}/
|
|
loop: "{{ directories }}"
|
|
|
|
- name: Unmount the volume
|
|
ansible.posix.mount:
|
|
path: /media/nas
|
|
state: unmounted
|
|
become: true
|
|
|
|
- name: Shutdown nas
|
|
ansible.builtin.shell: sudo shutdown -h 1
|