Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When try upload docker(hosted) repository from backup he was not uploaded #571

Closed
vvvvvvch opened this issue Apr 26, 2024 · 4 comments
Closed
Labels
bug Something isn't working pinned

Comments

@vvvvvvch
Copy link

What happened:

We has two nexus3 - old and new. We try create backup docker(hosted) repository from nexus.old and upload to nexus.new.
For this used https://github.com/030/n3dr/blob/main/cmd/n3dr/repositoriesV2.go#L63C98-L63C111

First, create backup

n3dr repositoriesV2 -u admin -p admin -n nexus.old \
    --dockerPort 8445 --dockerHost http://nexus.old \
    --showLogo=false --logFile ./std-out-backup-docker.log --logLevel=debug \
    --backup --directory-prefix ./nx --n3drRepo nx_docker_hosted

The command executed without errors. Something has downloaded.
In nexus.new create docker(hosted) repository "nx_docker_hosted" and execute script

n3dr repositoriesV2 -u admin -p admin -n nexus.new \
    --showLogo=false --logFile ./std-out-upload-docker.log --logLevel=debug --https=false \
    --upload --directory-prefix ./nx/

Command write this in log and nothing uploaded

time="2024-04-23T12:37:04+03:00" level=info msg="found the following localDiskRepos: '[nx_docker_hosted]'" func="github.com/030/n3dr/internal/app/n3dr/artifactsv2/upload.(*Nexus3).reposOnDisk" file="/home/runner/work/n3dr/n3dr/internal/app/n3dr/artifactsv2/upload/upload.go:84"
time="2024-04-23T12:37:04+03:00" level=info msg="Uploading files to Nexus: 'nexus.da.lan' repository: 'nx_docker_hosted'..." func="github.com/030/n3dr/internal/app/n3dr/artifactsv2/upload.(*Nexus3).uploadArtifactsSingleDir" file="/home/runner/work/n3dr/n3dr/internal/app/n3dr/artifactsv2/upload/upload.go:717"
time="2024-04-23T12:37:05+03:00" level=info msg="format of repo: 'nx_docker_hosted' is: '' and repoType: ''" func="github.com/030/n3dr/internal/app/n3dr/artifactsv2/upload.(*Nexus3).repoFormatLocalDiskRepo" file="/home/runner/work/n3dr/n3dr/internal/app/n3dr/artifactsv2/upload/upload.go:113"
time="2024-04-23T12:37:05+03:00" level=error msg="repoFormat not detected. Verify whether repo: 'nx_docker_hosted' resides in Nexus" func="github.com/030/n3dr/internal/app/n3dr/artifactsv2/upload.(*Nexus3).uploadArtifactsSingleDir" file="/home/runner/work/n3dr/n3dr/internal/app/n3dr/artifactsv2/upload/upload.go:733"
time="2024-04-23T12:37:05+03:00" level=debug msg="n3dr was running for: '88.28997ms'" func=main.execute.func1 file="/home/runner/work/n3dr/n3dr/cmd/n3dr/root.go:64"

What you expected to happen:

  1. n3dr should(?) create backup of docker(hosted) repository
  2. n3dr should(?) upload from backup to new docker(hosted) repository

Backup\upload docker repositories is supported by n3dr or I do something wrong?

How to reproduce it (as minimally and precisely as possible):

Anything else we need to know?:

nexus.old and nexus.new - two separate servers
all scripts are executed from "same as nexus server" linux machine (not in a nexus servers)

Environment:

  • nexus version: OSS 3.43.0-01 (new), OSS 3.29.2-02 (old)
  • n3dr version (use n3dr -v): n3dr version refs/tags/7.5.2 (installed from snap)
  • OS (e.g: cat /etc/os-release): ubuntu 22.04 lts server
  • Kernel (e.g. uname -a):
  • Others:
@vvvvvvch vvvvvvch added the bug Something isn't working label Apr 26, 2024
@030 030 added the pinned label Apr 26, 2024
@030
Copy link
Owner

030 commented Apr 26, 2024

@vvvvvvch Did you create the docker repository in your new nexus server? Could you check this doc?

@vvvvvvch
Copy link
Author

@030 Yes, repository created and I try backup\upload right like in docker.md

If this help, that is my steps

  1. Create repository in new nexus server with the same name like in old nexus server (with the same repo settings)
  2. execute script below
#!/bin/bash

## Nexus variable
nx_user="admin"
nx_pwd="admin"
nx_url="nexus.old"
nx_backup_prefix="./nxbackup"
nx_brepo_name="nx_docker_hosted"

nx2_user="admin"
nx2_pwd="admin"
nx2_url="nexus.new"
nx_upload_dir="./nxupload/"

nx_dport="8446"
nx_dhost="https://nexus.old"
nx2_dhost="https://nexus.new"

flogs="./std-out-nx-temp.log"

nx_backup(){
    n3dr repositoriesV2 -u $nx_user -p $nx_pwd -n $nx_url \
        --dockerPort $nx_dport --dockerHost $nx_dhost \
        --showLogo=false --logFile $flogs --logLevel=debug --https=false \
        --backup --directory-prefix $nx_backup_prefix --n3drRepo $nx_brepo_name
}

nx_upload(){
    n3dr repositoriesV2 -u $nx2_user -p $nx2_pwd -n $nx2_url \
        --showLogo=false --logFile $flogs --logLevel=debug --https=false \
        --dockerPort $nx_dport --dockerHost $nx2_dhost \
        --upload --directory-prefix $nx_upload_dir
}

nx_backup
mv "$nx_backup_prefix/$nx_brepo_name" "$nx_upload_dir"
nx_upload

Everything seems to be the same as described in the documentation

Debug Log: n3dr-backup-upload.log

But I don’t understand, is this a problem with the script or something with the code? What also confuses me is that the size of the backup copy of docker repository is in Kb.

030 added a commit that referenced this issue Apr 27, 2024
030 added a commit that referenced this issue Apr 27, 2024
030 added a commit that referenced this issue Apr 27, 2024
030 added a commit that referenced this issue Apr 27, 2024
030 added a commit that referenced this issue Apr 27, 2024
030 added a commit that referenced this issue Apr 27, 2024
030 added a commit that referenced this issue Apr 27, 2024
030 added a commit that referenced this issue Apr 27, 2024
@vvvvvvch
Copy link
Author

One small question about backup docker repositories

When I backup repo, who contain images with command

n3dr repositoriesV2 -u $nx_user -p $nx_pwd -n $nx_url \
        --dockerPort $nx_dport --dockerHost $nx_dhost \
        --showLogo=false --logFile $flogs --logLevel=debug --https=false \
        --backup --directory-prefix $nx_backup_prefix --n3drRepo $nx_brepo_name

What I should get in backup directory? I has only some manifests from repository, not images.

@vvvvvvch
Copy link
Author

In general, after several days of research, this utility is not entirely suitable for me personally. The --backup flag makes a copy of the entire nexus. The --n3drRepo flag does not support docker. And the p2iwd utility does not work quite correctly with the registry that nexus creates. As a result, I converted backup\upload to a simple bash script.

IMAGES=$(curl -s "https://$NEXUS_OLD_URL/v2/_catalog" | jq -r '.repositories[]')
for image in $IMAGES; do
    TAGS=$(curl -s "https://$NEXUS_OLD_URL/v2/$image/tags/list" | jq -r '.tags[]')
    for tag in $TAGS; do
        docker pull "$NEXUS_OLD_URL/$image:$tag"
        docker tag "$NEXUS_OLD_URL/$image:$tag" "$NEXUS_NEW_URL/$image:$tag"
        docker push "$NEXUS_NEW_URL/$image:$tag"
        # docker rmi "$NEXUS_NEW_URL/$image:$tag"
    done
done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pinned
Projects
None yet
Development

No branches or pull requests

2 participants