Harbor Data Loss scenario: Upgrade of harbor-container-registry tile results in data loss. smoke-test errand shows error: "run-errand smoke-testing --when-changed" and "Exit Status: 1"
alias docker="docker -H unix:///var/vcap/sys/run/docker/dockerd.sock"
alias docker-compose="docker-compose -H unix:///var/vcap/sys/run/docker/dockerd.sock -f /var/vcap/packages/harbor-app/docker-compose.yml"
Prepare the harbor-db:v2.10.0, which supports migrating from PostgreSQL 13 to 14
docker pull goharbor/harbor-db:v2.10.0
If we can't pull the goharbor/harbor-db:v2.10.0 image due to the network limitation, we can prepare the image using the following commands in the jumper vm
docker pull goharbor/harbor-db:v2.10.0
docker save goharbor/harbor-db:v2.10.0 -o harbor-db.tar
bosh -d harbor-container-registry-7ddbfeb36ca038df9f79 scp harbor-db.tar harbor-app:/tmp/harbor-db.tar
bosh -d harbor-container-registry-7ddbfeb36ca038df9f79 ssh harbor-app -c "sudo /var/vcap/jobs/harbor/packages/docker/bin/docker -H unix:///var/vcap/sys/run/docker/dockerd.sock load -i /tmp/harbor-db.tar" bosh -d harbor-container-registry-7ddbfeb36ca038df9f79 ssh harbor-app -c "rm /tmp/harbor-db.tar"
Edit docker-compose.yaml to use harbor-db:v2.10.0
sed -i "s/harbor-db:v2.11.0/harbor-db:v2.10.0/g" /var/vcap/packages/harbor-app/docker-compose.yml
Remove PostgreSQL 15 data that doesn't have data for Harbor 2.7
rm -rf /var/vcap/store/harbor/database/pg15
Ensure the /var/vcap/store/harbor/database/pg13 owner and group are runit-log. NOTE: This step is very Important
ls -l /var/vcap/store/harbor/database/
# Run the chown when owner:group if it is notrunit-log:runit-log # chown -R runit-log:runit-log /var/vcap/store/harbor/database/pg13
Run harbor 2.11.0 with harbor-db:v2.10.0
docker-compose up -d
Check the data of Harbor 2.7 has been recovered
Wait for the database to be migrated from 13 to 14
# ls to ensure /var/vcap/store/harbor/database/pg13 is migrated to /var/vcap/store/harbor/database/pg14
# migration is down when pg13 is gone
ls /var/vcap/store/harbor/database/
We can also check the harbor-db logs to ensure they contain "upgrade DB from 13 to 14" and "Upgrade Complete."
docker logs harbor-db
Log in to the Harbor ui to ensure the data of Harbor 2.7 is recovered
Migrate the database data from PostgreSQL 14 to 15
docker-compose stop
sed -i "s/harbor-db:v2.10.0/harbor-db:v2.11.0/g" /var/vcap/packages/harbor-app/docker-compose.yml
docker-compose up -d
Check the harbor-db logs to ensure it contains "upgrade DB from 14 to 15."
# ls to ensure /var/vcap/store/harbor/database/pg14 is migrated to /var/vcap/store/harbor/database/pg15
ls /var/vcap/store/harbor/database/
# check the logs of the harbor-db to ensure the it contains "upgrade DB from 14 to 15" and "Upgrade Complete"
docker logs harbor-db
Log in to the harbor ui to ensure the data still exists