apiVersion: batch/v1 kind: Job metadata: name: gitea-postgres-migrate-to-longhorn namespace: gitea spec: backoffLimit: 2 template: metadata: name: gitea-postgres-migrate-to-longhorn spec: restartPolicy: Never containers: - name: migrate image: alpine:3.20 command: - sh - -c - | set -euo pipefail apk add --no-cache rsync findutils coreutils src_count="$(find /source -mindepth 1 | wc -l | tr -d ' ')" echo "Source entries before copy: ${src_count}" rsync -aHAX --numeric-ids --delete /source/ /target/ target_count="$(find /target -mindepth 1 | wc -l | tr -d ' ')" echo "Target entries after copy: ${target_count}" test -f /target/PG_VERSION test -d /target/base test "${target_count}" -gt 0 echo "Top-level target contents:" ls -la /target echo "Migration verification successful" volumeMounts: - name: source mountPath: /source readOnly: true - name: target mountPath: /target volumes: - name: source persistentVolumeClaim: claimName: postgres-pvc - name: target persistentVolumeClaim: claimName: postgres-longhorn-pvc