Search code examples
dockerdocker-registryharbor

How to delete repositories and artifacts from Harbor when files don't exist anymore


We have a unique setup where we use Harbor as a mirror. So we setup a registry and replication, so we could pull from another repository.

But since we are just pulling, we don't need to backup the files of the artifacts. We just want to backup the setup, and if we need to restore, we can just pull again.

I tried to backup the database, redis, etc. And then I reinstalled a fresh Harbor, and restored those data. It worked! My problem is, it thinks the instance still have the binaries of all the data it pulled before. I don't know how to clean this up. If I execute the replication, it does not pull anymore because harbor thinks we have the latest data.

Any ideas what I can do? Maybe execute some sql commands? that sounds too intrusive.


Solution

  • Actual image layers are never stored in the DB, only the information about those. Layers are stored on File system or S3.

    If you need to restore in proxy mode,

    1. Before backup, delete in harbor all data in the proxy project.

    or alternatively

    1. Back up the DB, and exclude the image information from the DB
    • artifact*
    • blob
    • project_blop
    • repository
    • tag