summaryrefslogtreecommitdiffstats
path: root/bin/setup_borgbackup
diff options
context:
space:
mode:
authorTharre <tharre3@gmail.com>2018-05-09 02:58:18 +0200
committerTharre <tharre3@gmail.com>2018-05-09 17:28:13 +0200
commit321d9a8247d50cd634615ffed707aed3f4376108 (patch)
tree32fbd27e3a9e8c3f41d68232ffe203ef0ce10999 /bin/setup_borgbackup
parent3cb67ddae1d11e4cda22b9843665b6d3775828da (diff)
downloaddotfiles-321d9a8247d50cd634615ffed707aed3f4376108.tar.gz
dotfiles-321d9a8247d50cd634615ffed707aed3f4376108.tar.xz
dotfiles-321d9a8247d50cd634615ffed707aed3f4376108.zip
Move various scripts and functions into bin/
Diffstat (limited to 'bin/setup_borgbackup')
-rwxr-xr-xbin/setup_borgbackup18
1 files changed, 18 insertions, 0 deletions
diff --git a/bin/setup_borgbackup b/bin/setup_borgbackup
new file mode 100755
index 0000000..6e857a1
--- /dev/null
+++ b/bin/setup_borgbackup
@@ -0,0 +1,18 @@
+#!/bin/sh -e
+
+BORG_SECRET=~/.borg_secret
+BORG_SSH_KEY=~/.ssh/borg_key
+
+if [ ! -f "$BORG_SECRET" ]; then
+ install -m600 /dev/null "$BORG_SECRET"
+ pass backups/$(hostname) > "$BORG_SECRET"
+fi
+
+if [ ! -f "$BORG_SSH_KEY" ]; then
+ ssh-keygen -q -N "" -f "$BORG_SSH_KEY"
+ KEY=$(< ${BORG_SSH_KEY}.pub)
+
+ printf '%s\n' "command=\"cd /srv/borgbackup/repos/$(hostname);borg serve --restrict-to-path /srv/borgbackup/repos/$(hostname)\",restrict $KEY" | ssh "$1" "cat >> /srv/borgbackup/.ssh/authorized_keys"
+
+ echo "Added key to remote server."
+fi