goharbor / goharbor/harbor-cli

[feature]: Implement `harbor backup` / configuration export command

Open
#1,034 3 comments 0 reactions 0 assignees View on GitHub
discussion enhancement status/needs-info
Dominant language
Go
Stars
163
Forks
211
Avg merge
1m
Merged PRs (30d)
1

Description

## Problem
Currently, Harbor administrators who want to migrate servers, recreate environments for testing, or maintain GitOps workflows have no easy way to backup or export their Harbor registry configurations natively from the CLI. They have to manually recreate users, projects, quotas, and webhooks via the Web UI or write custom API scripts.
## Proposed Solution
I propose adding a new CLI command group for configuration backups: `harbor backup` (or `harbor export`).
This command will communicate with the Harbor API to fetch system configurations, projects, webhooks, and replication rules, and dump them into a structured YAML file (e.g., `backup.yaml`).
**Proposed CLI Usage:**
```bash
# Export all configurations to a YAML file
harbor backup --output harbor-backup.yaml
# Export only specific resources (optional future enhancement)
harbor backup --resources projects,users
Implementation Approach:

Create a backup subcommand in cmd/harbor/root/backup.go.
Use the existing pkg/api SDK wrappers to fetch all relevant Harbor settings.
Serialize the API response models into a declarative YAML structure and write it to disk.
Alternatives Considered
Writing external python/bash scripts utilizing the REST API, but having this natively integrated into the official CLI provides a much better UX.
Depending on database-level backups, which is often too heavy and risky for simple configuration migrations.
Additional Context
This lays the groundwork for a future harbor restore command, bringing "Infrastructure as Code" (GitOps) capabilities natively to the Harbor CLI.

Contributor guide

Open the contributing guide

Research direction

Start with the existing CLI command structure and the proposed entry point cmd/harbor/root/backup.go, then inspect the pkg/api SDK wrappers for the Harbor resources named in the issue. Define the export scope and declarative YAML shape before implementation; done means harbor backup --output harbor-backup.yaml retrieves the agreed configurations and writes a structured backup file.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.