summaryrefslogtreecommitdiff
path: root/ansible/roles
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-03-20 08:53:57 +0200
committerLars Wirzenius <liw@liw.fi>2022-03-20 08:53:57 +0200
commit02389f07bd7dc6f67387a6d441c7185c76de147e (patch)
tree6661f5f264e3f9a7e36946866e7a8796febb633a /ansible/roles
parent15a28130d0c65169925453db4481685a87aaf1b9 (diff)
downloadansibleness-02389f07bd7dc6f67387a6d441c7185c76de147e.tar.gz
holywood2: use rsync instead of borg for backups
Sponsored-by: author
Diffstat (limited to 'ansible/roles')
-rwxr-xr-xansible/roles/holywood2/files/rsync-to-nalanda33
-rwxr-xr-xansible/roles/holywood2/files/rsync-to-nalanda-all12
-rw-r--r--ansible/roles/holywood2/tasks/main.yml49
3 files changed, 63 insertions, 31 deletions
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