fix(backup): run forgejo dump in-pod to avoid exec websocket EOF
Long forgejo dump sessions were aborting kubectl exec with websocket close 1006. Launch dump via nohup inside the pod and poll for the zip.
This commit is contained in:
parent
de8f11e721
commit
e644ce150f
1 changed files with 23 additions and 1 deletions
|
|
@ -74,8 +74,30 @@ ok "forgejo-db" "${FORGEJO_DB_NAMESPACE}/${FORGEJO_DB_POD}"
|
|||
# 1. Application dump (repos, packages, attachments, LFS, avatars)
|
||||
ok "forgejo dump" "running in pod…"
|
||||
DUMP_REMOTE="/tmp/forgejo-backup-${TS}.zip"
|
||||
# Long dumps drop the kubectl exec websocket if attached to the process; run in-pod
|
||||
# background and poll for the archive file instead.
|
||||
kubectl exec --request-timeout=0 -n "${FORGEJO_NAMESPACE}" "${PROD_POD}" -c gitea -- \
|
||||
forgejo dump -f "${DUMP_REMOTE}"
|
||||
sh -eu -c "rm -f '${DUMP_REMOTE}'; nohup forgejo dump -f '${DUMP_REMOTE}' >/tmp/forgejo-dump.log 2>&1 &"
|
||||
dump_wait=0
|
||||
while [[ "${dump_wait}" -lt 1800 ]]; do
|
||||
if kubectl exec --request-timeout=30 -n "${FORGEJO_NAMESPACE}" "${PROD_POD}" -c gitea -- \
|
||||
test -s "${DUMP_REMOTE}" 2>/dev/null; then
|
||||
if kubectl exec --request-timeout=30 -n "${FORGEJO_NAMESPACE}" "${PROD_POD}" -c gitea -- \
|
||||
sh -c "pgrep -f 'forgejo dump' >/dev/null"; then
|
||||
sleep 10
|
||||
dump_wait=$((dump_wait + 10))
|
||||
continue
|
||||
fi
|
||||
break
|
||||
fi
|
||||
sleep 10
|
||||
dump_wait=$((dump_wait + 10))
|
||||
done
|
||||
if ! kubectl exec --request-timeout=30 -n "${FORGEJO_NAMESPACE}" "${PROD_POD}" -c gitea -- \
|
||||
test -s "${DUMP_REMOTE}" 2>/dev/null; then
|
||||
bad "forgejo dump" "timed out or empty archive (see /tmp/forgejo-dump.log in pod)"
|
||||
exit 1
|
||||
fi
|
||||
# Large dumps (~700M) fail via stdout stream or single kubectl cp — use chunks.
|
||||
dump_size="$(kubectl exec -n "${FORGEJO_NAMESPACE}" "${PROD_POD}" -c gitea -- \
|
||||
stat -c%s "${DUMP_REMOTE}" 2>/dev/null || echo 0)"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue