This repository was archived by the owner on Jan 24, 2026. It is now read-only.
forked from goharbor/harbor
-
Notifications
You must be signed in to change notification settings - Fork 6
chore: sync with upstream goharbor/harbor #130
Open
github-actions
wants to merge
26
commits into
next
Choose a base branch
from
sync-upstream-0br5e0r
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
2dbf830
fix error related to search user and search groups (#22606)
stonezdj ddb73e4
refine apitest to adopt proxy environment (#22706)
MinerYang 7f5ac5b
add per-endpoint CA certificate support for registry endpoints (#22535)
wy65701436 e7f0333
Add Cosign keyless signing for Harbor release artifacts (#22578)
Aloui-Ikram 0c3f6c7
Allows OIDC integration to handle the case where a user only has a si…
lfrancke 76f0a46
refactor: use strings.Cut to simplify code (#22590)
liuyueyangxmu 44d78af
fix: typos in comments (#22738)
NAM-MAN fbc0ebd
fix(session): fix invalid data type in SessionRegenerate (#22726)
liubin d35103b
chore(deps): bump sigstore/cosign-installer from 3.7.0 to 4.0.0 (#22732)
dependabot[bot] 0d142b8
Add oci type support for jfrog registry (#22589)
stonezdj 4a1a49d
Bump up trivy and trivy-adapter (#22745)
reasonerjt 47fef5f
ci: migrate build workflows to ubuntu-latest runners (#22750)
chlins 8d7b973
ci: fix the publishImage script with new docker version (#22753)
chlins 34affcb
update swagger file for creating tag (#22754)
wy65701436 bc4304e
Fix goroutine leak in StopAndWait by buffering errChan (#22740)
remo-lab 2a29db9
docs/makefile-commands (#22605)
intojhanurag 9ce30f8
Add pprof support (#22005)
strigazi 6606d18
fix(exporter): Export Harbor version via Prometheus exporter binary. …
Vad1mo 63a3071
chore(deps): update github.com/Masterminds/semver to v3 (#22411)
Juneezee c90b4a1
Contrib backup/restore scripts (#21971)
teletechie 295d094
Fix(portal): Restore Missing i18n Translation Keys (#22722)
bupd 7c74943
Fix: Hide alert messages irrelevant to users in UI (#21972)
bupd 64b8a02
feat: Add Style Linters (usestdlibvars, dupl) (#22670)
bupd 4fa6a27
Merge remote-tracking branch 'upstream/main' into next
github-actions[bot] 203122a
chore: sync with upstream goharbor/harbor
Vad1mo 24b8236
style: format code with Gofumpt and Prettier
deepsource-autofix[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| # Harbor Backup and Restore Scripts (Contrib) | ||
|
|
||
| **Warning:** These scripts are provided as-is in the `contrib/backup-restore` directory. They are not officially maintained or supported by the Harbor project. Use them at your own risk and ensure you understand their functionality before running them in a production environment. | ||
|
|
||
| These scripts (`harbor-backup` and `harbor-restore`) are provided as a convenience for backing up and restoring your Harbor instance. They aim to back up the following components: | ||
|
|
||
| * Harbor Database (PostgreSQL) | ||
| * Container Registry Data | ||
| * Chart Museum Data (if enabled) | ||
| * Redis Data (if enabled) | ||
| * Secret Keys | ||
| * Harbor Configuration (`harbor.yml`) | ||
|
|
||
| ### Features | ||
| Compared to the scripts the harbor project used to have in their repo this set of scripts is more robust in its error handling and also offers features | ||
| for not packing the backup into a tarball. This makes it easy to rsync the whole backup directory to a secondary/standby node and restore there. | ||
|
|
||
| rsync is used extensively by the script. by leaving the files in the backup directory between runs the downtime for backup is greatly reduced at the | ||
| expense of disk space usage. | ||
|
|
||
| Supports logging of status messages directly to syslog | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| * **Docker:** These scripts rely on the `docker` command-line interface to interact with Harbor's containers. Ensure Docker is installed and accessible on the machine where you run these scripts. | ||
| * **Sufficient Permissions:** You'll need appropriate permissions (e.g., `sudo` or being in the `docker` group) to run Docker commands and perform file system operations. | ||
| * **Stopped Harbor Instance:** You must stop your Harbor instance completely before running the `harbor-backup` or `harbor-restore` script to avoid data inconsistencies. | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Backup (`harbor-backup`) | ||
|
|
||
| 1. **Download the Scripts:** Place the `harbor-backup` script in a location accessible from your Harbor instance. Within the Harbor repository, this would typically be under `contrib/backup-restore/`. | ||
|
|
||
| 2. **Make it Executable:** | ||
| ```bash | ||
| chmod +x harbor-backup | ||
| ``` | ||
|
|
||
| 3. **Run the Backup Script:** | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: The backup steps instruct running the script before stopping Harbor, which contradicts the prerequisite and can lead to inconsistent backups. Reorder the steps so Harbor is stopped before invoking the backup script. Prompt for AI agents |
||
| ```bash | ||
| ./harbor-backup [OPTIONS] | ||
| ``` | ||
| 3. **Stop Harbor:** Ensure your Harbor instance is completely stopped before proceeding with the backup. | ||
|
|
||
| 4. **Options:** | ||
| * `--docker-cmd <command>`: Specify the Docker command to use (default: `docker`). | ||
| * `--db-image <image>`: Specify the Harbor database image to use for the temporary backup container (default: auto-detected). It's generally recommended to let it auto-detect. | ||
| * `--db-path <path>`: Harbor DB data path (default: `/data/database`). Adjust if your deployment uses a different path. | ||
| * `--registry-path <path>`: Registry data path (default: `/data/registry`). Adjust if your deployment uses a different path. | ||
| * `--chart-museum-path <path>`: Chart Museum data path (default: `/data/chart_storage`). Adjust if your deployment uses a different path. | ||
| * `--redis-path <path>`: Redis data path (default: `/data/redis`). Adjust if your deployment uses a different path. | ||
| * `--secret-path <path>`: Secret data path (default: `/data/secret`). Adjust if your deployment uses a different path. | ||
| * `--config-path <path>`: Harbor configuration file path (default: `/etc/harbor/harbor.yml`). Adjust if your deployment uses a different path. | ||
| * `--backup-dir <path>`: Directory where the backup will be stored (default: `harbor_backup`). | ||
| * `--no-archive`: Do not create a `tar.gz` archive of the backup directory. The backup will remain as a directory structure in `$BACKUP_DIR/harbor`. | ||
| * `--use-syslog`: Use syslog for logging output. | ||
| * `--log-level <level>`: Set the logging level (default: `INFO`, options: `DEBUG`, `INFO`, `NOTICE`, `WARNING`, `ERROR`, `CRITICAL`, `ALERT`, `EMERGENCY`). | ||
| * `--help`: Display this help message. | ||
|
|
||
| 5. **Backup Location:** By default, the backup will be created in a directory named `harbor_backup` in the current working directory. If the `--no-archive` option is not used, the final backup will be a compressed tarball named `harbor_backup.tar.gz` within the `harbor_backup` directory. | ||
|
|
||
| ### Restore (`harbor-restore`) | ||
|
|
||
| 1. **Download the Scripts:** Place the `harbor-restore` script in a location accessible from your Harbor instance. Within the Harbor repository, this would typically be under `contrib/backup-restore/`. | ||
|
|
||
| 2. **Make it Executable:** | ||
| ```bash | ||
| chmod +x harbor-restore | ||
| ``` | ||
|
|
||
| 3. **Stop Harbor:** Ensure your Harbor instance is completely stopped before proceeding with the restore. | ||
|
|
||
| 4. **Run the Restore Script:** | ||
| ```bash | ||
| ./harbor-restore [OPTIONS] | ||
| ``` | ||
|
|
||
| 5. **Options:** The restore script accepts similar options to the backup script, allowing you to specify the Docker command, database image, data paths, and the backup directory. | ||
|
|
||
| * `--backup-dir <path>`: **Crucially**, this should point to the directory containing your Harbor backup (either the `harbor` subdirectory extracted from the tarball or the `harbor_backup` directory if `--no-archive` was used). | ||
| * `--no-archive`: Use this option if your backup is already extracted into the `$BACKUP_DIR/harbor` directory. If your backup is a `tar.gz` file, **do not** use this option; the script will attempt to extract it. | ||
|
|
||
| *(Other options like `--docker-cmd`, `--db-image`, `--db-path`, `--registry-path`, `--chart-museum-path`, `--redis-path`, `--secret-path`, `--config-path`, `--use-syslog`, and `--log-level` function similarly to the backup script.)* | ||
|
|
||
| 6. **Restore Process:** The script will: | ||
| * Start a temporary database container. | ||
| * Extract the backup archive (if not using `--no-archive`). | ||
| * Drop and recreate existing Harbor databases. | ||
| * Restore the database content from the backed-up SQL files. | ||
| * Synchronize the registry, chart museum, Redis, and secret data directories. | ||
| * Restore the Harbor configuration file. | ||
| * Clean up the temporary database container. | ||
|
|
||
| 7. **Restart Harbor:** Once the restore script completes successfully, you can restart your Harbor instance. | ||
|
|
||
| ## Important Notes | ||
|
|
||
| * **Backup Consistency:** For a consistent backup, it's recommended to stop your Harbor instance or at least ensure minimal write activity during the backup process. | ||
| * **Database Image Tag:** In production environments, it's advisable to use a specific tag for the `--db-image` option in both the backup and restore scripts to ensure consistency. | ||
| * **Custom Deployments:** If you have a highly customized Harbor deployment with data stored in non-default locations, you **must** use the appropriate command-line options to point the scripts to the correct paths. | ||
| * **Testing:** Always test the backup and restore process in a non-production environment before relying on it for critical data. | ||
| * **Unsupported:** Remember that these scripts are provided in the `contrib/backup-restore/` directory. They may not be actively maintained, and you might encounter issues. Contributions and improvements from the community are welcome. | ||
|
|
||
| ## Contributing | ||
|
|
||
| If you find issues or have improvements to these scripts, feel free to submit pull requests to the Harbor project in the `contrib/backup-restore/` directory. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: The new verification guide link is broken because docs/signature-verification.md is not present in the repo. Remove the link or add the referenced documentation file.
Prompt for AI agents