From b5c67b6da935f2f541c03c0be5ad00172603c05e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 18 Sep 2024 16:15:02 +0900 Subject: [PATCH] add new backup via restic --- backup-via-restic | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 backup-via-restic diff --git a/backup-via-restic b/backup-via-restic new file mode 100755 index 0000000..7250d21 --- /dev/null +++ b/backup-via-restic @@ -0,0 +1,32 @@ +#!/bin/sh +# Nico Schottelius, 2024-09-18, Deokso +# Mainly written for my notebooks + +set -x + +# Run before: restic -r s3:${endpoint}/${bucket_name}/restic init + +name=nico +endpoint=s3.k8s.place5.ungleich.ch + +export KUBECONFIG=~/k8s/p5-admin.conf + +bucket_name=$(kubectl -n rook-ceph get configmap -o yaml ${name}-bucket-claim | yq .data.BUCKET_NAME) + +export AWS_ACCESS_KEY_ID=$(kubectl -n rook-ceph get secrets -o yaml ${name}-bucket-claim | yq .data.AWS_ACCESS_KEY_ID | base64 -d ; echo "") +export AWS_SECRET_ACCESS_KEY=$(kubectl -n rook-ceph get secrets -o yaml ${name}-bucket-claim | yq .data.AWS_SECRET_ACCESS_KEY | base64 -d ; echo "") + + +repo=s3:${endpoint}/${bucket_name}/restic + +export RESTIC_PASSWORD="$(pass git co nico-privat >/dev/null 2>&1; pass notebook/restic-password)" + +restic -r ${repo} backup \ + --exclude ~/Nextcloud \ + --exclude ~/movies/ \ + --exclude ~/.cdist \ + --exclude ~/.cache \ + --exclude ~/.config/**/cache \ + ~/ + +restic -r ${repo} forget --keep-last 20 --prune