How to backup and restore the Harbor tile in VMware PKS environment
search cancel

How to backup and restore the Harbor tile in VMware PKS environment

book

Article ID: 345063

calendar_today

Updated On:

Products

VMware

Issue/Introduction

This article contains information about how to backup and restore the Harbor in VMware PKS environment.


Environment

VMware PKS 1.x

Cause

Harbor VM backup with traditional backup methods is not supported and there is no inbuilt feature Tile to take Backup.

Resolution

To backup the Harbor Tile:

  1. Login to the Harbor tile VM using the Credentials available under Harbor tile > Credentials > harbor-app VM Credentials in the Ops Manager Dashboard.

  2. Find a disk which has enough space, usually located in /var/vcap/store, create a backup directory named backup under it.

  3. Run sudo -i to get to root mode privileges.

  4. Download script 67558_harbor-backup.zip attached in this KB article, extract it to get the script 67558_harbor-backup.sh file nd copy it to /var/vcap/store/backup.

    Note: Use Winscp for file transfer or create a new file using vi command and paste the content.

  5. Issue the following command to make the /var/vcap/store/backup/67558_harbor-backup.sh  script executable:

    chmod +x /var/vcap/store/backup/67558_harbor-backup.sh

  6. Stop the Harbor service by running the command (This will also stop the wavefront containers if it is enabled. Remember to run monit start wavefront when you start harbor at the end of this article):

    monit stop harbor

  7. Ensure that there is no container is running, if there is, stop them.

    alias docker='/var/vcap/packages/docker/bin/docker -H unix:///var/vcap/sys/run/docker/dockerd.sock'

    docker ps -a

  8. If there are leftover containers in docker ps -a preform the following steps (if not proceed with step 9):

    docker stop $(docker ps -aq) && docker rm $(docker ps -aq)

  9. Navigate to the backup directory and ensure that you have the script available here.

  10. To Back up all the data (Images, Database), run the script by executing the below command:
    ./67558_harbor-backup.sh -–istile

    Note: To backup only database data when harbor storage is NFS, GCP or S3, use –dbonly while running the script:
    ./67558_harbor-backup.sh --istile –dbonly

  11. Once the backup is completed, you see a harbor.tgz file under /var/vcap/store with backup data.
    ls  /var/vcap/store/backup

    67558_harbor-backup.sh    harbor.tgz

  12. You can start the Harbor service once the backup is completed. Also start wavefront if it is enabled on harbor.
    monit start harbor​​​​​​

    monit start wavefront


To restore the Harbor Tile:

  1. Install Harbor tile with the same configuration with the previous installation, such as the admin password, storage type configurations.

  2. Login to the Harbor tile VM using the Credentials available under Harbor tile > Credentials > harbor-app VM Credentials in the Ops Manager Dashboard.

  3. Run sudo -i to get to root mode privileges.

  4. Find a disk which has enough space, usually located in /var/vcap/store, create a restore directory in it.

  5. Download the script 67558_harbor-restore.zip attached in this KB article, extract it to get the script 67558_harbor-restore.sh and copy it to /var/vcap/store/restore.

    Note: Use Winscp for file transfer or create a new file using vi command and paste the content.

  6. Issue the following command to make the /var/vcap/store/backup/67558_harbor-restore.sh  script executable:

    chmod +x /var/vcap/store/backup/67558_harbor-restore.sh

  7. Stop the Harbor service by running the command (This will also stop the wavefront containers if it is enabled. Remember to run monit start wavefront when you start harbor at the end of this article):
    monit stop harbor

  8. Ensure that there is no container is running, if there is, stop it.
    alias docker='/var/vcap/packages/docker/bin/docker -H unix:///var/vcap/sys/run/docker/dockerd.sock'

    docker ps -a

  9. If there are leftover containers in docker ps -a preform the following steps (if not proceed with step 10):

    docker stop $(docker ps -aq) && docker rm $(docker ps -aq)

  10. Navigate to the backup directory and ensure that you have the script & backup data available here.

  11. To restore all the data (Images, Database), run the script by executing the below command:
    ./67558_harbor-restore.sh -–istile

    Note: To only restore database data when harbor storage is NFS, GCP or S3, use –dbonly while running the script:
    ./67558_harbor-restore.sh --istile –dbonly

  12. Start the Harbor service once the restoration is completed. Also start wavefront if it is enabled on harbor.
    monit start harbor​​​​​​

    monit start wavefront

  13. Verify all the Images and data present by logging into Harbor instance in the browser and browsing through the repositories under projects, and try pulling the images from K8S nodes.

  14. Remove all unused data in /var/vcap/store/restore if it’s not required anymore.
    rm -rf /var/vcap/store/restore



Attachments

67558_harbor-restore get_app
67558_harbor-backup get_app
67558_harbor-restore get_app
67558_harbor-backup get_app