Rebuild backup to nas to be used from minisforum.
This commit is contained in:
29
nas.yaml
29
nas.yaml
@@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
# This playbook creates a backup of minisforum and writes it to odroid.
|
# This playbook creates a backup of minisforum and writes it to odroid.
|
||||||
|
# Must be run on minisforum
|
||||||
- name: Backup minisforum to odroid
|
- name: Backup minisforum to odroid
|
||||||
hosts: all
|
hosts: all
|
||||||
vars:
|
vars:
|
||||||
@@ -9,51 +10,45 @@
|
|||||||
- nextcloud
|
- nextcloud
|
||||||
- sftp
|
- sftp
|
||||||
- strato-production
|
- strato-production
|
||||||
gather_facts: false
|
gather_facts: true
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Wakeup odroid
|
- name: Wakeup odroid
|
||||||
community.general.wakeonlan:
|
community.general.wakeonlan:
|
||||||
mac: '00:1E:06:45:4C:45'
|
mac: '00:1E:06:45:4C:45'
|
||||||
broadcast: 192.168.178.56
|
|
||||||
delegate_to: localhost
|
|
||||||
|
|
||||||
- name: Wait odroid is responding
|
- name: Wait odroid is responding
|
||||||
ansible.builtin.wait_for_connection:
|
ansible.builtin.wait_for:
|
||||||
|
host: 192.168.178.56
|
||||||
|
port: 2049
|
||||||
|
|
||||||
- name: Gathering facts
|
- name: Mount odroid storage
|
||||||
ansible.builtin.setup:
|
|
||||||
|
|
||||||
- name: Mount minisforum storage
|
|
||||||
ansible.posix.mount:
|
ansible.posix.mount:
|
||||||
src: 192.168.178.46:/
|
src: 192.168.178.56:/media/backup
|
||||||
path: /media/nas
|
path: /media/odroid
|
||||||
state: mounted
|
state: mounted
|
||||||
fstype: nfs
|
fstype: nfs
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
- name: Check backup directory exists
|
- name: Check backup directory exists
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: /media/backup/minisforum
|
path: /media/odroid/minisforum
|
||||||
state: directory
|
state: directory
|
||||||
mode: '0755'
|
mode: '0755'
|
||||||
|
|
||||||
- name: Check file path for storage directories exists
|
- name: Check file path for storage directories exists
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: /media/backup/minisforum/{{ item }}
|
path: /media/odroid/minisforum/{{ item }}
|
||||||
state: directory
|
state: directory
|
||||||
mode: '0755'
|
mode: '0755'
|
||||||
loop: "{{ directories }}"
|
loop: "{{ directories }}"
|
||||||
|
|
||||||
- name: Backup minisforum directories
|
- name: Backup minisforum directories
|
||||||
ansible.builtin.shell: rsync -a --delete /media/nas/{{ item }}/ /media/backup/minisforum/{{ item }}/
|
ansible.builtin.shell: rsync -a --delete /media/backup/{{ item }}/ /media/odroid/minisforum/{{ item }}/
|
||||||
loop: "{{ directories }}"
|
loop: "{{ directories }}"
|
||||||
|
|
||||||
- name: Unmount the volume
|
- name: Unmount the volume
|
||||||
ansible.posix.mount:
|
ansible.posix.mount:
|
||||||
path: /media/nas
|
path: /media/odroid
|
||||||
state: unmounted
|
state: unmounted
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
- name: Shutdown nas
|
|
||||||
ansible.builtin.shell: sudo shutdown -h 1
|
|
||||||
|
|||||||
Reference in New Issue
Block a user