k3s-configs/apps/gitea/restic-backup.sh

23 lines
615 B
Bash

#!/bin/sh
source .restic.env
# Set up colors
GREEN='\033[0;32m'
NC='\033[0m'
echo -e "\n${GREEN}`date` - Starting backup...${NC}\n"
# Gitea
echo -e "\n${GREEN}`date` - Backing up Gitea...${NC}\n"
gitea=$(kubectl get po -n gitea -l app=gitea -o name --no-headers=true)
kubectl scale --replicas=0 $gitea -n gitea
restic backup /gitea
restic backup /pg_backup/postgres_backup.dump
kubectl scale --replicas=1 $gitea -n gitea
# Forget and prune
echo -e "\n${GREEN}`date` - Running forget and prune...${NC}\n"
restic forget --prune --keep-daily 7 --keep-weekly 2
echo -e "\n${GREEN}`date` - Backup finished.${NC}\n"