From 02389f07bd7dc6f67387a6d441c7185c76de147e Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 20 Mar 2022 08:53:57 +0200 Subject: holywood2: use rsync instead of borg for backups Sponsored-by: author --- ansible/roles/holywood2/files/rsync-to-nalanda | 33 +++++++++++++++ ansible/roles/holywood2/files/rsync-to-nalanda-all | 12 ++++++ ansible/roles/holywood2/tasks/main.yml | 49 ++++++++-------------- 3 files changed, 63 insertions(+), 31 deletions(-) create mode 100755 ansible/roles/holywood2/files/rsync-to-nalanda create mode 100755 ansible/roles/holywood2/files/rsync-to-nalanda-all (limited to 'ansible/roles/holywood2') diff --git a/ansible/roles/holywood2/files/rsync-to-nalanda b/ansible/roles/holywood2/files/rsync-to-nalanda new file mode 100755 index 0000000..20f3cfe --- /dev/null +++ b/ansible/roles/holywood2/files/rsync-to-nalanda @@ -0,0 +1,33 @@ +#!/bin/bash + +set -euo pipefail + +from="$1" +server="$2" +dir="$3" +shift 3 + +new="$dir/new" +dated="$dir/$(date -Id)" + +echo "Syncing $from to staging area on $server" +rsync -rlthHS --partial --stats --exclude=lost+found \ + "$from/." "$server:$new/." "$@" +echo + +if ssh "$server" test -e "$dated"; then + echo "$dated exists, removing it" + ssh "$server" find "$dated" -type d -exec chmod +rw '{}' + + ssh "$server" rm -rf "$dated" +fi + +echo "Making a hardlink copy to $dated" +ssh "$server" mkdir "$dated" +ssh "$server" cp -al "$new/." "$dated/." + +echo +ssh "$server" df -h . +echo + +echo "All good" +echo diff --git a/ansible/roles/holywood2/files/rsync-to-nalanda-all b/ansible/roles/holywood2/files/rsync-to-nalanda-all new file mode 100755 index 0000000..5f58b53 --- /dev/null +++ b/ansible/roles/holywood2/files/rsync-to-nalanda-all @@ -0,0 +1,12 @@ +#!/bin/bash + +set -euo pipefail + +echo ================================================================== +./rsync-to-nalanda /mnt/soile liw-holywood@nalanda repo-soile + +echo ================================================================== +./rsync-to-nalanda /mnt/media liw-holywood@nalanda repo-media + +echo ================================================================== +echo "All backups to nalanda done" diff --git a/ansible/roles/holywood2/tasks/main.yml b/ansible/roles/holywood2/tasks/main.yml index f62f302..eb5e539 100644 --- a/ansible/roles/holywood2/tasks/main.yml +++ b/ansible/roles/holywood2/tasks/main.yml @@ -45,35 +45,22 @@ state: started enabled: yes -# - 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 +- name: install backup scripting + copy: + src: "{{ item }}" + dest: /root + owner: root + group: root + mode: 0755 + with_items: + - rsync-to-nalanda + - rsync-to-nalanda-all -# - name: run borg from cron -# copy: -# content: | -# 40 10 * * * root /root/borg-all -# dest: /etc/cron.d/local-backup -# owner: root -# group: root -# mode: 0755 +- name: run backups from cron + copy: + content: | + 40 10 * * * root /root/rsync-to-nalanda-all + dest: /etc/cron.d/local-backup + owner: root + group: root + mode: 0755 -- cgit v1.2.1