Bedford Backup
On this page
Backup Bedford Machines
This Ansible playbook performs automated backups of machines in the Bedford environment. It utilizes the BorgBackup tool for efficient and secure backups. The playbook also generates an SSH keypair for authentication and sets up a scheduled backup job using cron.
Play Variables
borgbackup_master: The master machine responsible for managing backups.
Play Tasks
Ensure BorgBackup Installation
This task ensures that BorgBackup is installed on the target machines using Homebrew.
Module:
community.general.homebrew- name: Ensure borgbackup is installed community.general.homebrew: name: borgbackup state: presentGenerate Keypair
This task generates an SSH keypair for authentication purposes.
Module:
community.crypto.openssh_keypair- name: Generate keypair community.crypto.openssh_keypair: path: /Users/{{ ansible_user }}/.ssh/borgbackup register: keypairPrint Public Key
This task prints the generated public key to the console.
Module:
ansible.builtin.debug- name: "Print public key" ansible.builtin.debug: msg: "Public key: {{ keypair.public_key }}"Copy the Client Script
This task copies a client script template to the target machine, which is used for initiating backups.
Module:
ansible.builtin.template- name: Copy the client script become: true ansible.builtin.template: src: templates/borg_client.sh.j2 dest: /usr/local/bin/borg_client.sh mode: 755Create Backup Job
This task sets up a scheduled backup job using the cron service. The backup job runs daily at 2:00 AM and executes the client script.
Module:
ansible.builtin.cron- name: Create backup job become: true ansible.builtin.cron: name: borg backup minute: "0" hour: "2" user: root job: /usr/local/bin/borg_client.sh
This playbook automates the process of setting up backups for machines in the Bedford environment, ensuring data safety and recovery. The SSH keypair generated adds an extra layer of security to the backup process, and the cron job ensures regular and consistent backups.