migrate borg backups to ssh backup services

This commit is contained in:
2025-05-04 00:48:13 +00:00
parent 5454d9c35a
commit 622c84c6be
2 changed files with 23 additions and 18 deletions

View File

@@ -61,7 +61,7 @@ spec:
- name: REPO_SYNC_MAX_SIZE
value: "4294967296" # 4GB
value: "6442450944" # 6GB
- name: BORG_KEY_FILE
value: /root/.borg/key
@@ -73,6 +73,10 @@ spec:
SCRIPT_START_TIME=$(date +%s)
# while true; do
# sleep 5
# done
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
@@ -83,16 +87,16 @@ spec:
borg compact ${BORG_REPO}
# check repo size
REPO_SIZE_IN_BYTES=$(${BORG_RSH} mf@backupsrv01.dev.lan "du -b ~/borg-repos/git.limbosolutions.com --max-depth=0 | cut -f1 ")
REPO_SIZE_IN_BYTES=$(${BORG_RSH} mf@backupsrv01.dev.lan -p 2222 "du -b ~/borg-repos/git.limbosolutions.com -d 0 | cut -f1 ")
echo "Repository size: $((REPO_SIZE_IN_BYTES / 1024 / 1024)) MB"
if [ $REPO_SIZE_IN_BYTES -gt $REPO_SYNC_MAX_SIZE ]; then \
echo 'Repository size exceeds $REPO_SYNC_MAX_SIZE';
echo "ERROR: Repository size exceeds $REPO_SYNC_MAX_SIZE";
exit 1;
else
# Repository size is within limits for offsite sync
# ssh to backup server and enforce rclone to onedrive
${BORG_RSH} mf@backupsrv01.dev.lan \
${BORG_RSH} mf@backupsrv01.dev.lan -p 2222 \
"rclone sync ~/borg-repos/git.limbosolutions.com mf.onedrive:.backups/git.limbosolutions.com/borg" && \
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))) "