aaawq
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
---
|
||||
- name: Install backup software and configure backup to Synology NAS
|
||||
hosts: ubugpu.localdomain
|
||||
hosts: all
|
||||
become: false
|
||||
vars_files:
|
||||
- vault.yml
|
||||
@@ -65,11 +65,11 @@
|
||||
when: ssh_key_path is defined
|
||||
|
||||
- name: Ensure .ssh directory exists on the NAS
|
||||
command: "ssh alex@alex-ds414.localdomain 'mkdir -p ~/.ssh && chmod 700 ~/.ssh'"
|
||||
command: "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null alex@alex-ds414.localdomain 'mkdir -p ~/.ssh && chmod 700 ~/.ssh'"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Add the SSH public key to the NAS authorized_keys
|
||||
command: "ssh alex@alex-ds414.localdomain 'echo {{ ssh_pub_key.content | b64decode }} >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys'"
|
||||
command: "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null alex@alex-ds414.localdomain 'echo {{ ssh_pub_key.content | b64decode }} >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys'"
|
||||
when: ssh_key_path is defined
|
||||
|
||||
- name: Show debug info for rsync_user and rsync_password
|
||||
@@ -87,7 +87,7 @@
|
||||
timeout: 60
|
||||
|
||||
- name: Check if NAS is reachable via SSH
|
||||
command: "ssh -o BatchMode=yes -o ConnectTimeout=5 alex@alex-ds414.localdomain echo 'SSH connection successful'"
|
||||
command: "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o BatchMode=yes -o ConnectTimeout=5 alex@alex-ds414.localdomain echo 'SSH connection successful'"
|
||||
register: nas_ping_result
|
||||
ignore_errors: yes
|
||||
|
||||
@@ -97,7 +97,7 @@
|
||||
when: nas_ping_result.rc != 0
|
||||
|
||||
- name: Perform the test rsync
|
||||
command: rsync -av --dry-run --delete {{ backup_dir }}/ alex@alex-ds414.localdomain:{{ nas_target_base }}/{{ hostname }}/
|
||||
command: rsync -av --dry-run --delete --info=progress2 {{ backup_dir }}/ alex@alex-ds414.localdomain:{{ nas_target_base }}/{{ hostname }}/
|
||||
register: rsync_test
|
||||
ignore_errors: yes
|
||||
failed_when: rsync_test.rc not in [0, 23]
|
||||
@@ -108,7 +108,7 @@
|
||||
when: rsync_test.rc not in [0, 23]
|
||||
|
||||
- name: Perform the backup using rsync
|
||||
command: rsync -av --delete {{ backup_dir }}/ alex@alex-ds414.localdomain:{{ nas_target_base }}/{{ hostname }}/
|
||||
command: rsync -av --delete --info=progress2 {{ backup_dir }}/ alex@alex-ds414.localdomain:{{ nas_target_base }}/{{ hostname }}/
|
||||
when: rsync_test.rc in [0, 23]
|
||||
ignore_errors: yes
|
||||
failed_when: rsync_test.rc not in [0, 23]
|
||||
@@ -128,7 +128,7 @@
|
||||
day: "{{ cron_time.split()[2] }}"
|
||||
month: "{{ cron_time.split()[3] }}"
|
||||
weekday: "{{ cron_time.split()[4] }}"
|
||||
job: "sudo etherwake -i {{ network_interface }} 00:11:32:43:FA:11 && sleep 300 && rsync -av --delete /home/ alex@alex-ds414.localdomain:{{ nas_target_base }}/{{ hostname }}/"
|
||||
when: rsync_test.rc in [0, 23] and (cron_present is not defined or cron_present is failed)
|
||||
job: "sudo etherwake -i {{ network_interface }} 00:11:32:43:FA:11 && sleep 300 && rsync -av --info=progress2 --delete /home/ alex@alex-ds414.localdomain:{{ nas_target_base }}/{{ hostname }}/"
|
||||
when: rsync_test.rc == 0 and (cron_present is not defined or cron_present is failed)
|
||||
become: yes
|
||||
|
||||
|
||||
Reference in New Issue
Block a user