- name: Ubuntu Data Backup Automation
hosts: from_server
become: yes
vars:
source_dir: “/path/to/source” # Change to the actual folder to back up
dest_dir: “/path/to/destination” # Change to the actual backup location on TO server
to_server: “to_server_user@to_server_ip”
ssh_key: “~/.ssh/id_rsa” # Change to the correct SSH key tasks:- name: Install rsync if not present
apt:
name: rsync
state: present - name: Ensure SSH key exists for passwordless authentication
ansible.builtin.copy:
src: “{{ ssh_key }}.pub”
dest: “/home/{{ ansible_user }}/.ssh/authorized_keys”
remote_src: yes - name: Create cron job for periodic backup
ansible.builtin.cron:
name: “Automated Data Backup”
minute: “0”
hour: “*/6” # Runs every 6 hours
job: “rsync -az –delete -e ‘ssh -i {{ ssh_key }}’ {{ source_dir }}/ {{ to_server }}:{{ dest_dir }}/”
- name: Install rsync if not present
Ubuntu Data Backup Automation

<summary> .NET Awesome Links BPMN BPMS c# Chocolatey Cluster Server Command Window Community Edition Dance DataGrid Diff DiffFiles Dig Examples Font Family FORTRAN go Google Admin Toolbox Install LibreCAD MinGW OpenForm OpenRadioss Opensource ParaView PhotoScapeX pip Prompt QCAD tags Tips Violin WP Control WPF xps15 zbuild 一括変更 罫線 色

コメントを残す
コメントを投稿するにはログインしてください。