backups: git.limbosolutions.com/kb/borg-backup:latest alpine revision
This commit is contained in:
29
README.md
29
README.md
@@ -5,19 +5,18 @@ Welcome to public repository of my [Git Server](https://git.limbosolutions.com)
|
|||||||
Using [gitea](https://git.limbosolutions.com/kb/gitea) as git server.
|
Using [gitea](https://git.limbosolutions.com/kb/gitea) as git server.
|
||||||
|
|
||||||
- [Setup](#setup)
|
- [Setup](#setup)
|
||||||
- [kubernetes Namespace](#kubernetes-namespace)
|
- [kubernetes Namespace](#kubernetes-namespace)
|
||||||
- [Add Help Chart](#add-help-chart)
|
- [Add Help Chart](#add-help-chart)
|
||||||
- [Update Helm charts](#update-helm-charts)
|
- [Update Helm charts](#update-helm-charts)
|
||||||
- [Install / Update](#install--update)
|
- [Install / Update](#install--update)
|
||||||
- [ssh ingress](#ssh-ingress)
|
- [ssh ingress](#ssh-ingress)
|
||||||
|
|
||||||
- [Backups](#backups)
|
- [Backups](#backups)
|
||||||
- [secrets](#secrets)
|
- [secrets](#secrets)
|
||||||
- [Proxmox Backup Server (kubernetes cron job)](#proxmox-backup-server-kubernetes-cron-job)
|
- [Proxmox Backup Server (kubernetes cron job)](#proxmox-backup-server-kubernetes-cron-job)
|
||||||
- [Borg and Offsite sync (kubernetes cron job)](#borg-and-offsite-sync-kubernetes-cron-job)
|
- [Borg and Offsite sync (kubernetes cron job)](#borg-and-offsite-sync-kubernetes-cron-job)
|
||||||
- [borgbackup sidekick](#borgbackup-sidekick)
|
- [borgbackup sidekick](#borgbackup-sidekick)
|
||||||
- [Create borgbackup-sidekick pod](#create-borgbackup-sidekick-pod)
|
- [Create borgbackup-sidekick pod](#create-borgbackup-sidekick-pod)
|
||||||
- [Remove borgbackup-sidekick pod](#remove-borgbackup-sidekick-pod)
|
- [Remove borgbackup-sidekick pod](#remove-borgbackup-sidekick-pod)
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
@@ -71,10 +70,10 @@ set +a
|
|||||||
envsubst < ./backups/gitea-backup-secrets.yaml | kubectl apply -n git-limbosolutions-com -f -
|
envsubst < ./backups/gitea-backup-secrets.yaml | kubectl apply -n git-limbosolutions-com -f -
|
||||||
|
|
||||||
SSH_ID_RSA=$(echo -n "$SSH_ID_RSA" | base64 -w 0)
|
SSH_ID_RSA=$(echo -n "$SSH_ID_RSA" | base64 -w 0)
|
||||||
BORG_KEY_FILE=$(echo -n "$BORG_KEY_FILE" | base64 -w 0)
|
BORG_KEY=$(echo -n "$BORG_KEY" | base64 -w 0)
|
||||||
|
|
||||||
kubectl patch secret gitea-backup-secret --patch "{\"data\":{\"SSH_ID_RSA\":\"$SSH_ID_RSA\"}}" -n git-limbosolutions-com
|
kubectl patch secret gitea-backup-secret --patch "{\"data\":{\"ssh_id_rsa\":\"$SSH_ID_RSA\"}}" -n git-limbosolutions-com
|
||||||
kubectl patch secret gitea-backup-secret --patch "{\"data\":{\"BORG_KEY_FILE\":\"$BORG_KEY_FILE\"}}" -n git-limbosolutions-com
|
kubectl patch secret gitea-backup-secret --patch "{\"data\":{\"borg_key\":\"$BORG_KEY\"}}" -n git-limbosolutions-com
|
||||||
```
|
```
|
||||||
|
|
||||||
### Proxmox Backup Server (kubernetes cron job)
|
### Proxmox Backup Server (kubernetes cron job)
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ spec:
|
|||||||
containers:
|
containers:
|
||||||
- name: gitea-pbs-client
|
- name: gitea-pbs-client
|
||||||
image: git.limbosolutions.com/kb/pbsclient
|
image: git.limbosolutions.com/kb/pbsclient
|
||||||
|
imagePullPolicy: Always
|
||||||
env:
|
env:
|
||||||
- name: MODE
|
- name: MODE
|
||||||
value: shell
|
value: shell
|
||||||
@@ -48,17 +49,17 @@ spec:
|
|||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: gitea-backup-secret
|
name: gitea-backup-secret
|
||||||
key: PBS_REPOSITORY
|
key: pbs_repository
|
||||||
- name: PBS_PASSWORD
|
- name: PBS_PASSWORD
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: gitea-backup-secret
|
name: gitea-backup-secret
|
||||||
key: PBS_PASSWORD
|
key: pbs_password
|
||||||
- name: PBS_FINGERPRINT
|
- name: PBS_FINGERPRINT
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: gitea-backup-secret
|
name: gitea-backup-secret
|
||||||
key: PBS_FINGERPRINT
|
key: pbs_fingerprint
|
||||||
|
|
||||||
command: ["bash", "-c"]
|
command: ["bash", "-c"]
|
||||||
args:
|
args:
|
||||||
|
|||||||
@@ -33,9 +33,12 @@ spec:
|
|||||||
mountPath: /root/.gitea-inline-config
|
mountPath: /root/.gitea-inline-config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
containers:
|
containers:
|
||||||
- name: borg-client
|
- name: borg-client
|
||||||
image: git.limbosolutions.com/kb/borg-backup:latest
|
image: git.limbosolutions.com/kb/borg-backup:latest
|
||||||
|
imagePullPolicy: Always
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
memory: "512Mi"
|
memory: "512Mi"
|
||||||
@@ -48,35 +51,33 @@ spec:
|
|||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: gitea-backup-secret
|
name: gitea-backup-secret
|
||||||
key: BORG_REPO
|
key: borg_repo
|
||||||
|
|
||||||
- name: BORG_PASSPHRASE
|
- name: BORG_PASSPHRASE
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: gitea-backup-secret
|
name: gitea-backup-secret
|
||||||
key: BORG_PASSPHRASE
|
key: borg_passphrase
|
||||||
|
|
||||||
- name: BORG_RSH
|
- name: BORG_RSH
|
||||||
value: ssh -o StrictHostKeyChecking=no -o LogLevel=ERROR
|
value: ssh -p 2222 -o StrictHostKeyChecking=no -o LogLevel=ERROR
|
||||||
|
|
||||||
|
|
||||||
- name: REPO_SYNC_MAX_SIZE
|
- name: REPO_SYNC_MAX_SIZE
|
||||||
value: "6442450944" # 6GB
|
value: "6442450944" # 6GB
|
||||||
|
|
||||||
- name: BORG_KEY_FILE
|
|
||||||
value: /root/.borg/key
|
|
||||||
|
|
||||||
command: ["sh", "-c"]
|
command: ["bash", "-c"]
|
||||||
args:
|
args:
|
||||||
- |
|
- |
|
||||||
set -e
|
set -e
|
||||||
|
source loadenv
|
||||||
|
|
||||||
SCRIPT_START_TIME=$(date +%s)
|
SCRIPT_START_TIME=$(date +%s)
|
||||||
|
|
||||||
# while true; do
|
# while true; do
|
||||||
# sleep 5
|
# sleep 5
|
||||||
# done
|
# done
|
||||||
|
|
||||||
|
|
||||||
borg create ${BORG_REPO}::postgresql-export-$(date +%Y%m%d%H%M%S) /data/postgresql-export
|
borg create ${BORG_REPO}::postgresql-export-$(date +%Y%m%d%H%M%S) /data/postgresql-export
|
||||||
borg create ${BORG_REPO}::gitea-data-$(date +%Y%m%d%H%M%S) /data/gitea-data
|
borg create ${BORG_REPO}::gitea-data-$(date +%Y%m%d%H%M%S) /data/gitea-data
|
||||||
@@ -87,7 +88,7 @@ spec:
|
|||||||
borg compact ${BORG_REPO}
|
borg compact ${BORG_REPO}
|
||||||
|
|
||||||
# check repo size
|
# check repo size
|
||||||
REPO_SIZE_IN_BYTES=$(${BORG_RSH} mf@backupsrv01.dev.lan -p 2222 "du -b ~/borg-repos/git.limbosolutions.com -d 0 | cut -f1 ")
|
REPO_SIZE_IN_BYTES=$(remote-connect du -b "$SSH_FOLDER" -d 0 | awk '{print $1}')
|
||||||
echo "Repository size: $((REPO_SIZE_IN_BYTES / 1024 / 1024)) MB"
|
echo "Repository size: $((REPO_SIZE_IN_BYTES / 1024 / 1024)) MB"
|
||||||
|
|
||||||
if [ $REPO_SIZE_IN_BYTES -gt $REPO_SYNC_MAX_SIZE ]; then \
|
if [ $REPO_SIZE_IN_BYTES -gt $REPO_SYNC_MAX_SIZE ]; then \
|
||||||
@@ -96,8 +97,7 @@ spec:
|
|||||||
else
|
else
|
||||||
# Repository size is within limits for offsite sync
|
# Repository size is within limits for offsite sync
|
||||||
# ssh to backup server and enforce rclone to onedrive
|
# ssh to backup server and enforce rclone to onedrive
|
||||||
${BORG_RSH} mf@backupsrv01.dev.lan -p 2222 \
|
remote-connect "rclone sync ~/borg-repos/git.limbosolutions.com mf_onedrive:.backups/git.limbosolutions.com/borg" && \
|
||||||
"rclone sync ~/borg-repos/git.limbosolutions.com mf_onedrive:.backups/git.limbosolutions.com/borg" && \
|
|
||||||
SCRIPT_DURATION=$(($(date +%s) - SCRIPT_START_TIME)) && \
|
SCRIPT_DURATION=$(($(date +%s) - SCRIPT_START_TIME)) && \
|
||||||
echo "INFO: Finished Backup of git.limbosolutions.com (offsite) ($((SCRIPT_DURATION / 60 / 60)):$((SCRIPT_DURATION / 60)):$((SCRIPT_DURATION % 60))) "
|
echo "INFO: Finished Backup of git.limbosolutions.com (offsite) ($((SCRIPT_DURATION / 60 / 60)):$((SCRIPT_DURATION / 60)):$((SCRIPT_DURATION % 60))) "
|
||||||
fi
|
fi
|
||||||
@@ -105,6 +105,7 @@ spec:
|
|||||||
#outputs info
|
#outputs info
|
||||||
borg info ${BORG_REPO}
|
borg info ${BORG_REPO}
|
||||||
#borg info ${BORG_REPO} --json
|
#borg info ${BORG_REPO} --json
|
||||||
|
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: gitea-data
|
- name: gitea-data
|
||||||
mountPath: /data/gitea-data
|
mountPath: /data/gitea-data
|
||||||
@@ -114,15 +115,17 @@ spec:
|
|||||||
subPath: postgresql-export
|
subPath: postgresql-export
|
||||||
|
|
||||||
- name: gitea-backup-secret
|
- name: gitea-backup-secret
|
||||||
mountPath: /root/.borg/key
|
mountPath: /root/.ssh/id_rsa
|
||||||
subPath: BORG_KEY_FILE
|
subPath: ssh_id_rsa
|
||||||
|
readOnly: true
|
||||||
|
|
||||||
- name: gitea-backup-secret
|
- name: gitea-backup-secret
|
||||||
mountPath: /root/.ssh/id_rsa
|
mountPath: /app/borg/key
|
||||||
subPath: SSH_ID_RSA
|
subPath: borg_key
|
||||||
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
|
|
||||||
- name: gitea-data
|
- name: gitea-data
|
||||||
persistentVolumeClaim:
|
persistentVolumeClaim:
|
||||||
claimName: gitea-shared-storage
|
claimName: gitea-shared-storage
|
||||||
@@ -130,7 +133,7 @@ spec:
|
|||||||
- name: gitea-inline-config
|
- name: gitea-inline-config
|
||||||
secret:
|
secret:
|
||||||
secretName: gitea-inline-config
|
secretName: gitea-inline-config
|
||||||
|
|
||||||
- name: gitea-backup-secret
|
- name: gitea-backup-secret
|
||||||
secret:
|
secret:
|
||||||
secretName: gitea-backup-secret
|
secretName: gitea-backup-secret
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ spec:
|
|||||||
containers:
|
containers:
|
||||||
- name: borgbackup-sidekick
|
- name: borgbackup-sidekick
|
||||||
image: git.limbosolutions.com/kb/borg-backup:latest
|
image: git.limbosolutions.com/kb/borg-backup:latest
|
||||||
|
imagePullPolicy: Always
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
memory: "512Mi"
|
memory: "512Mi"
|
||||||
@@ -21,18 +22,18 @@ spec:
|
|||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: gitea-backup-secret
|
name: gitea-backup-secret
|
||||||
key: BORG_REPO
|
key: borg_repo
|
||||||
|
|
||||||
- name: BORG_PASSPHRASE
|
- name: BORG_PASSPHRASE
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: gitea-backup-secret
|
name: gitea-backup-secret
|
||||||
key: BORG_PASSPHRASE
|
key: borg_passphrase
|
||||||
|
|
||||||
- name: BORG_RSH
|
- name: BORG_RSH
|
||||||
value: ssh -o StrictHostKeyChecking=no
|
value: ssh -p 2222 -o StrictHostKeyChecking=no -o LogLevel=ERROR
|
||||||
|
|
||||||
- name: BORG_KEY_FILE
|
- name: borg_key_file
|
||||||
value: /root/.borg/key
|
value: /root/.borg/key
|
||||||
|
|
||||||
command: ["sh", "-c"]
|
command: ["sh", "-c"]
|
||||||
@@ -44,13 +45,14 @@ spec:
|
|||||||
|
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
|
|
||||||
- name: gitea-backup-secret
|
- name: gitea-backup-secret
|
||||||
mountPath: /root/.borg/key
|
mountPath: /root/.ssh/id_rsa
|
||||||
subPath: BORG_KEY_FILE
|
subPath: ssh_id_rsa
|
||||||
|
readOnly: true
|
||||||
|
|
||||||
- name: gitea-backup-secret
|
- name: gitea-backup-secret
|
||||||
mountPath: /root/.ssh/id_rsa
|
mountPath: /app/borg/key
|
||||||
subPath: SSH_ID_RSA
|
subPath: borg_key
|
||||||
volumes:
|
volumes:
|
||||||
- name: gitea-backup-secret
|
- name: gitea-backup-secret
|
||||||
secret:
|
secret:
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ metadata:
|
|||||||
namespace: git-limbosolutions-com
|
namespace: git-limbosolutions-com
|
||||||
type: Opaque
|
type: Opaque
|
||||||
stringData:
|
stringData:
|
||||||
PBS_REPOSITORY: ${PBS_REPOSITORY}
|
pbs_repository: ${PBS_REPOSITORY}
|
||||||
PBS_PASSWORD: ${PBS_PASSWORD}
|
pbs_password: ${PBS_PASSWORD}
|
||||||
PBS_FINGERPRINT: ${PBS_FINGERPRINT}
|
pbs_fingerprint: ${PBS_FINGERPRINT}
|
||||||
BORG_REPO: ${BORG_REPO}
|
borg_repo: ${BORG_REPO}
|
||||||
BORG_PASSPHRASE: ${BORG_PASSPHRASE}
|
borg_passphrase: ${BORG_PASSPHRASE}
|
||||||
#SSH_ID_RSA: ""
|
#SSH_ID_RSA: ""
|
||||||
#BORG_KEY_FILE: ""
|
#BORG_KEY: ""
|
||||||
|
|
||||||
Reference in New Issue
Block a user