offsite backup revision

This commit is contained in:
2025-09-21 19:47:55 +00:00
parent 79ee2b8e55
commit 4e777b8b86
2 changed files with 14 additions and 7 deletions

View File

@@ -59,19 +59,27 @@ spec:
name: gitea-backup-secret
key: borg_passphrase
- name: OFFSITE_TARGET_FOLDER
valueFrom:
secretKeyRef:
name: gitea-backup-secret
key: offsite_target_folder
- name: BORG_RSH
value: ssh -p 2222 -o StrictHostKeyChecking=no -o LogLevel=ERROR
- name: REPO_SYNC_MAX_SIZE
value: "10737418240" # 10GB
- name: MODE
value: SHELL
command: ["bash", "-c"]
args:
- |
set -e
source loadenv
SCRIPT_START_TIME=$(date +%s)
@@ -88,7 +96,7 @@ spec:
borg compact ${BORG_REPO}
# check repo size
REPO_SIZE_IN_BYTES=$(remote-connect du -b "$SSH_FOLDER" -d 0 | awk '{print $1}')
REPO_SIZE_IN_BYTES=$(remote-get-folder-size)
echo "Repository size: $((REPO_SIZE_IN_BYTES / 1024 / 1024))MB"
if [ $REPO_SIZE_IN_BYTES -gt $REPO_SYNC_MAX_SIZE ]; then \
@@ -97,8 +105,7 @@ spec:
else
# Repository size is within limits for offsite sync
# ssh to backup server and enforce rclone to onedrive
remote-connect "rclone sync ~/borg-repos/git.limbosolutions.com mf_onedrive:.backups/git.limbosolutions.com/borg" && \
SCRIPT_DURATION=$(($(date +%s) - SCRIPT_START_TIME)) && \
remote-connect "rclone sync $SSH_FOLDER $OFFSITE_TARGET_FOLDER --progress" && \
echo "INFO: Finished Backup of git.limbosolutions.com (offsite) ($((SCRIPT_DURATION / 60 / 60)):$((SCRIPT_DURATION / 60)):$((SCRIPT_DURATION % 60))) "
fi
@@ -123,7 +130,6 @@ spec:
mountPath: /app/borg/key
subPath: borg_key
volumes:
- name: gitea-data

View File

@@ -11,6 +11,7 @@ stringData:
pbs_fingerprint: ${PBS_FINGERPRINT}
borg_repo: ${BORG_REPO}
borg_passphrase: ${BORG_PASSPHRASE}
offsite_target_folder: ${OFFSITE_TARGET_FOLDER}
#SSH_ID_RSA: ""
#BORG_KEY: ""