From c7912e21bbf298d6d8095ef802aab4482c97bf07 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Mon, 9 Jul 2018 09:57:29 +0300 Subject: Change: smarthost-client role, backups for holywood2 --- ansible/roles/holywood2/files/borg-all | 17 +++++++++++++++++ ansible/roles/holywood2/files/run-borg | 22 ++++++++++++++++++++++ ansible/roles/holywood2/tasks/main.yml | 24 ++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100755 ansible/roles/holywood2/files/borg-all create mode 100755 ansible/roles/holywood2/files/run-borg (limited to 'ansible/roles/holywood2') diff --git a/ansible/roles/holywood2/files/borg-all b/ansible/roles/holywood2/files/borg-all new file mode 100755 index 0000000..bbc982a --- /dev/null +++ b/ansible/roles/holywood2/files/borg-all @@ -0,0 +1,17 @@ +#!/bin/sh + +ts="$(date +%Y-%m-%dT%H:%M:%S)" + +echo "Backing up /mnt/soile" +./run-borg willikins /mnt/backups/borg create -p --stats ::"soile-$ts)" /mnt/soile/ + +echo "Backing up /mnt/media" +./run-borg willikins /mnt/backups/borg create -p --stats ::"media-$ts)" /mnt/media/ + +echo "Backing up /mnt/liw-backups" +./run-borg willikins /mnt/backups/borg create -p --stats ::"liw-$ts)" /mnt/liw-backups/ + +echo "Pruning" +./run-borg willikins /mnt/backups/borg prune --keep-with 100d + +echo "Backup finished" diff --git a/ansible/roles/holywood2/files/run-borg b/ansible/roles/holywood2/files/run-borg new file mode 100755 index 0000000..7225a94 --- /dev/null +++ b/ansible/roles/holywood2/files/run-borg @@ -0,0 +1,22 @@ +#!/bin/sh + +set -eu + +hostname="$(hostname)" +target="$1" +export targetdir="$2" +shift 2 + +export BORG_REPO="$target:$targetdir" +export BORG_PASSCOMMAND="cat /etc/borg-passphrase" + +if borg init --encryption=repokey +then + borg upgrade --disable-tam +fi + +DATE="$(date +%Y-%m-%dT%H%M%S)" + +echo borg "$@" +borg "$@" +echo borg finished diff --git a/ansible/roles/holywood2/tasks/main.yml b/ansible/roles/holywood2/tasks/main.yml index fbd5224..a6a7171 100644 --- a/ansible/roles/holywood2/tasks/main.yml +++ b/ansible/roles/holywood2/tasks/main.yml @@ -22,3 +22,27 @@ owner: root group: root mode: 0644 + +- name: install borg + apt: + name: borgbackup + default_release: stretch-backports + +- name: install borg scripting + copy: + src: "{{ item }}" + dest: /root + owner: root + group: root + mode: 0755 + with_items: + - run-borg + - borg-all + +- name: install borg passphrase + copy: + content: "{{ lookup('pipe', 'pass borg/holywood2-to-willikins') }}" + dest: /etc/borg-passphrase + owner: root + group: root + mode: 0600 -- cgit v1.2.1