nsbin/backup-via-restic

42 lines
1.3 KiB
Text
Raw Permalink Normal View History

2024-09-18 07:15:02 +00:00
#!/bin/sh
# Nico Schottelius, 2024-09-18, Deokso
# Mainly written for my notebooks
# 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)"
2024-09-18 07:21:41 +00:00
# Allow sing restic directly
if [ $# -ge 1 ]; then
restic -r ${repo} "$@"
else
restic -r ${repo} backup \
2024-09-18 07:15:02 +00:00
--exclude ~/Nextcloud \
2024-09-18 07:15:45 +00:00
--exclude ~/Downloads \
2024-09-18 07:15:02 +00:00
--exclude ~/movies/ \
--exclude ~/.cdist \
2024-09-22 08:38:55 +00:00
--exclude ~/.mu/xapian \
2024-09-18 07:15:02 +00:00
--exclude ~/.cache \
2024-09-18 16:59:18 +00:00
--exclude ~/.cargo \
2024-09-18 17:01:10 +00:00
--exclude ~/.local/share/Trash \
2024-09-18 07:15:02 +00:00
--exclude ~/.config/**/cache \
2024-09-18 14:31:23 +00:00
--exclude ~/.minikube/cache \
--exclude ~/.config/**/logs \
2024-09-18 07:15:02 +00:00
~/
2024-09-18 07:21:41 +00:00
restic -r ${repo} forget --keep-last 20 --prune
fi