diff --git a/.gitea/workflows/backup.yml b/.gitea/workflows/backup.yml index f1e2d4d..e6f618b 100644 --- a/.gitea/workflows/backup.yml +++ b/.gitea/workflows/backup.yml @@ -8,7 +8,7 @@ on: required: false default: '' schedule: - - cron: '0 17 * * *' # UTC 17:00 == KST 02:00 + - cron: '0 17 * * 1-5' # UTC 17:00 == KST 02:00, Mon-Fri only jobs: backup: @@ -57,8 +57,6 @@ jobs: echo "::warning::TARGET_SEED_DEPTH(${TARGET_SEED_DEPTH}) is invalid; resetting to 50" TARGET_SEED_DEPTH=50 fi - CACHE_BASE="${ROOT_DIR}/.cache_sources" - mkdir -p "${CACHE_BASE}" TOTAL_SUCCESS=0 TOTAL_SKIP=0 TOTAL_ERROR=0 @@ -247,48 +245,13 @@ jobs: exit 1 fi - prepare_cache() { - local source_repo="$1" cache_dir="${CACHE_BASE}/${source_repo//\//_}.git" - if [[ ! -d "${cache_dir}" ]]; then - echo "Initializing local cache for ${source_repo} at ${cache_dir}" - if ! git clone --mirror "${SOURCE_SSH_HOST}:${source_repo}" "${cache_dir}"; then - echo "::warning::Failed to clone cache for ${source_repo} (${SOURCE_SSH_HOST}:${source_repo})" - return 1 - fi - else - echo "Refreshing cache for ${source_repo}" - if ! git -C "${cache_dir}" fetch --prune --prune-tags origin "+refs/*:refs/*"; then - echo "::warning::Failed to refresh cache for ${source_repo} (${SOURCE_SSH_HOST}:${source_repo})" - return 1 - fi - fi - SOURCE_CACHE_PATH["${source_repo}"]="${cache_dir}" - } - - echo "Preparing per-source caches..." - for source_repo in "${!SOURCE_REPOS[@]}"; do - prepare_cache "${source_repo}" || echo "::warning::Cache unavailable for ${source_repo}; will fallback to direct fetch" - done - echo "Step 1) 소스 브랜치 해시 스캔" for source_repo in "${!SOURCE_REPOS[@]}"; do - cache_dir="${SOURCE_CACHE_PATH[${source_repo}]:-}" source_repo_url="${SOURCE_SSH_HOST}:${source_repo}" - if [[ -n "${cache_dir}" && -d "${cache_dir}" ]]; then - echo " - using cache: ${cache_dir}" - if ! remote_output=$(git -C "${cache_dir}" for-each-ref --format='%(objectname)\t%(refname)' 'refs/heads/*'); then - echo "::warning::Failed to read heads from cache ${cache_dir}; falling back to remote ${source_repo_url}." - remote_output=$(git ls-remote --heads "${source_repo_url}") || { - echo "::warning::Failed to ls-remote ${source_repo_url}. Entries for this repo may fail." - continue - } - fi - else - echo " - ${source_repo_url}" - if ! remote_output=$(git ls-remote --heads "${source_repo_url}"); then - echo "::warning::Failed to ls-remote ${source_repo_url}. Entries for this repo may fail." - continue - fi + echo " - ${source_repo_url}" + if ! remote_output=$(git ls-remote --heads "${source_repo_url}"); then + echo "::warning::Failed to ls-remote ${source_repo_url}. Entries for this repo may fail." + continue fi if [[ -z "${remote_output}" ]]; then echo "::warning::No branches found for ${source_repo_url}" @@ -449,9 +412,9 @@ jobs: CLONE_DIR=$(mktemp -d) echo "Working directory: ${CLONE_DIR}" + SOURCE_FETCH_REMOTE="${SOURCE_SSH_HOST}:${source_repo}" if ${just_created}; then echo "Target repo newly created; cloning source branch for initial push..." - SOURCE_FETCH_REMOTE="${SOURCE_CACHE_PATH[${source_repo}]:-${SOURCE_SSH_HOST}:${source_repo}}" if ! git clone --bare --no-tags --single-branch --branch "${branch_name}" "${SOURCE_FETCH_REMOTE}" "${CLONE_DIR}"; then echo "::error::Failed to clone source repository ${SOURCE_FETCH_REMOTE}" notify_status "error" "${repo_name}" "${branch_name}" "${backup_mode}" "${start_epoch}" "source clone 실패" "${heads_detail}" @@ -475,7 +438,6 @@ jobs: continue fi git remote add origin "${GITEA_REMOTE}" - SOURCE_FETCH_REMOTE="${SOURCE_CACHE_PATH[${source_repo}]:-${SOURCE_SSH_HOST}:${source_repo}}" git remote add source "${SOURCE_FETCH_REMOTE}" fi