54 lines
1.4 KiB
YAML
54 lines
1.4 KiB
YAML
---
|
|
# This playbook creates a backup of odroid and writes it to the nas.
|
|
- name: Backup odroid to nas.
|
|
hosts: all
|
|
gather_facts: false
|
|
|
|
tasks:
|
|
- name: Backup odroid
|
|
block:
|
|
|
|
- name: Wakeup the nas
|
|
community.general.wakeonlan:
|
|
mac: '54:04:a6:f1:9b:80'
|
|
|
|
- name: Wait nas is responding
|
|
wait_for:
|
|
timeout: 90
|
|
delegate_to: localhost
|
|
|
|
- name: Check mount point exists
|
|
file:
|
|
path: /media/nas
|
|
state: directory
|
|
|
|
- name: Mount nas volume
|
|
ansible.posix.mount:
|
|
src: 192.168.178.50:/data
|
|
path: /media/nas
|
|
state: mounted
|
|
fstype: nfs
|
|
become: yes
|
|
|
|
- name: Backup docker data to nas
|
|
shell: rsync -a /media/backup/docker/ /media/nas/Odroid/docker
|
|
become: yes
|
|
|
|
- name: Backup hetzner data to nas
|
|
shell: rsync -a /media/backup/hetzner/ /media/nas/Odroid/hetzner
|
|
become: yes
|
|
|
|
- name: Backup nextcloud data to nas
|
|
shell: rsync -a /media/backup/nextcloud/ /media/nas/Odroid/nextcloud
|
|
become: yes
|
|
|
|
- name: Backup media to nas
|
|
shell: rsync -a /media/backup/media/ /media/nas/Odroid/media
|
|
become: yes
|
|
|
|
- name: Umount nas volume
|
|
ansible.posix.mount:
|
|
path: /media/nas
|
|
state: unmounted
|
|
become: yes
|