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

21 lines
596 B
Bash

#!/bin/sh
# 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 deploy -n gitea -l app=gitea -o name --no-headers=true)
kubectl scale -n gitea --replicas=0 $gitea
restic backup /gitea
restic backup /backup/postgres_backup.dump
kubectl scale -n gitea --replicas=1 $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"