Default Branch Gone after Upgrade

Just upgraded from 8.17 to 10.1. Noticed that the default branch for a repository did not carry over.

Upgrade process:
Run GitLab backup on 8.17
Spin up 8.17 docker container on new machine, restore from backup
PostgreSQL upgrade
Shutdown 8.17 container
Start up 10.1 container

Any reason for that? Where is that stored?

I had a similar problem with default branch. At that time, I just dumped default branch for all projects beforehand and then set them back afterward using the APIs (I’m still using v3 but may need to convert to use v4 for 10)

IFS='\r\n' GLOBIGNORE='*' command eval "PROJECTS_IDS=((cat “$WORKSPACE/$PROJECT_LIST”))"

for project_id in "${PROJECTS_IDS[@]}"; do
  [[ -z "$project_id" ]] && continue
    echo "project:${project_id}"
    project=$(curl --header "PRIVATE-TOKEN: ${PRIVATE_TOKEN}" --insecure "https://${COPY_FROM}/api/v3/projects/${project_id}")
    default_branch=$(echo "${project}" | jq -r '.default_branch')
    [[ "$default_branch" == "null" ]] && continue
    path_with_namespace=$(echo "${project}" | jq -r '.path_with_namespace')

    echo "${project_id},${default_branch}" >> "${WORKSPACE}/${PROJECT_BRANCH_LIST}"

declare -r PROJECT_DEFAULT_BRANCH_LIST=“changeDefaultBranch.txt” # project id,default branch name


for LINE in "${LINES[@]}"; do
  [[ -z "$LINE" ]] && continue
    IFS=, read -ra project <<< "${LINE}"
    curl -H 'Content-Type:application/json' -H 'Accept:application/json' --insecure -X PUT -d "{\"default_branch\":\"${project[1]}\"}" https://"${COPY_TO}"/api/v3/projects/"${project[0]}"?private_token="${PRIVATE_TOKEN}"
1 Like

@hozawa thank you! So it seems there are some variables here that are not defined. What is IFS? Where does $WORKSPACE and $PROJECT_LIST come from? I’d like to adapt this.

It’s just a bash script.
Meaning of IFS in bash can be found here:

WORKSPACE and $PROJECT_LIST are just variable names.

Alright so I couldn’t get the script from @hozawa to work out of the box. I wrote a Python script that should be much easier.

Hopefully anyone else who has this issue will find this useful!

1 Like