heximcz / routerboard-backup

Ultimate backup of yours mikrotik routerboards.
https://routerboard-backup.best-hosting.cz/
Other
43 stars 14 forks source link

Git Url - support group urls #2

Closed pcdog closed 8 years ago

pcdog commented 8 years ago

[Gitlab\Exception\ErrorException]
"name" can contain only letters, digits, '', '.', dash and space. It must start with letter, digit or ''.

=> I have gitlab with groups and projects within, eg

https://gitlab.org.tld/groupname/mikrotik-backup

From the yml file:

project-name: 'groupname/mikrotik-backup'

Does not work (with the above error)

THX for extending to that ;)

heximcz commented 8 years ago

check 'url:' parameter, it is gitlab api url, like this: http://**git.your-domain.com**/api/v3/

'project-name:' = is single name of the project, in your case, it should be 'mikrotik-backup'

Please test it again with this setup.

pcdog commented 8 years ago

[Gitlab\Exception\ErrorException]
"name" has already been taken, "path" has already been taken

As said, we do have groups and the projects are nested inside. I precreated the project to have it in the right group...

heximcz commented 8 years ago

ok, you are right. If project does not exist, script create new in default user, but when project does exist, backup will be send to right group. I'll be add 'group-name' parameter and group support in next version.

(In GitLab API is it: namespace_id (optional) - namespace for the new project (defaults to user))

pcdog commented 8 years ago

that sounds pretty much like it ;)

thanks. looking forward to it.

pcdog commented 8 years ago

mikrotik@i-can-haz-data:/opt/routerboard-backup$ php ./routerboard-backup.php rb:gitlab [2016-22-02 15:23:39] NOTICE: Group 'xx-maintainers' does not exist in repo. Creating new ...

[Gitlab\Exception\ErrorException]
Failed to save group {:path=>["has already been taken"]}

heximcz commented 8 years ago

So sorry, but I can not reproduce this issue. What version of the GitLab are you using?

[2016-22-02 19:39:31] NOTICE: Group 'xx-maintainers' does not exist in repo. Creating new ... [2016-22-02 19:39:31] NOTICE: Group 'xx-maintainers' has been created successfully. [2016-22-02 19:39:31] NOTICE: Project 'rb2' does not exist in repo. Creating new ... [2016-22-02 19:39:36] NOTICE: Project 'rb2' has been created successfully. [2016-22-02 19:39:36] INFO: Action: Backup all routers from backup list to GitLab. ...

heximcz commented 8 years ago

But I found a little bug in correct identification of the project ID depending on the group, try latest 0.8.2 please. Maybe it help with previous state.

pcdog commented 8 years ago

php ./routerboard-backup.php rb:gitlab [2016-23-02 17:20:58] NOTICE: Project 'mikrotik-backup' does not exist in repo. Creating new ...

[Exception]
Can not create new project in GitLab!

rb:gitlab [-i|--addr ADDR] [--] []

but it actually created it....!!

rerunning the commands then gives:

[Gitlab\Exception\ErrorException]
"name" has already been taken, "path" has already been taken

heximcz commented 8 years ago

What version of the GitLab are you using?

pcdog commented 8 years ago

Section: misc Installed-Size: 843369 Maintainer: GitLab B.V. Architecture: amd64 Version: 7.10.0~omnibus-1

Seems there is an upgrade, let me install it first.

pcdog commented 8 years ago

that is definitely wrong output before:

Deleting old backups ... skipping Unpacking gitlab-ce (8.5.0-ce.1) over (8.4.4-ce.0) ...

So 8.4.4 before (where it fails) 8.5.0 soon

heximcz commented 8 years ago

I tested it on GitLab version 8.4.4 and 8.5.0 without problems.

pcdog commented 8 years ago

you have jabber or something I can catch you at?

pcdog commented 8 years ago

Question: did your "group" preexist or are you creating that as well? I tried to put it in an existing group...

heximcz commented 8 years ago

It is no problem, project and group may or may not exist. Script automatically create new if does not exist. But user must have a right permission for it.

pcdog commented 8 years ago

new version: mikrotik@i-can-haz-data:/opt/routerboard-backup$ php ./routerboard-backup.php rb:gitlab [2016-23-02 17:50:37] NOTICE: Project 'mikrotik-backup' does not exist in repo. Creating new ...

[Exception]
Can not create new project in GitLab!

rb:gitlab [-i|--addr ADDR] [--] []

mikrotik@i-can-haz-data:/opt/routerboard-backup$ php ./routerboard-backup.php rb:gitlab [2016-23-02 17:50:46] NOTICE: Project 'mikrotik-backup' does not exist in repo. Creating new ...

[Gitlab\Exception\ErrorException]
"name" has already been taken, "path" has already been taken

rb:gitlab [-i|--addr ADDR] [--] []

mikrotik@i-can-haz-data:/opt/routerboard-backup$ php ./routerboard-backup.php rb:gitlab [2016-23-02 17:50:50] NOTICE: Project 'mikrotik-backup' does not exist in repo. Creating new ...

[Gitlab\Exception\ErrorException]
"name" has already been taken, "path" has already been taken

rb:gitlab [-i|--addr ADDR] [--] []

mikrotik@i-can-haz-data:/opt/routerboard-backup$

No idea now. any debug flag you can set?

heximcz commented 8 years ago

[Exception]: Can not create new project in GitLab! Indicates problem with permissions, or bad configuration. Check your config.yml, examle:

gitlab:
    # gitlab api url - like this: http://git.your-domain.com/api/v3/ (required)
    url: 'http://git.my-domain.cz/api/v3/'
    # gitlab username (required)
    username: 'rbackup'
    # gitlab project name (required)
    project-name: 'rbackup'
    # group name - user must have enabled premission for create new group (optional)
    # leave empty if you do not use a group
    group-name: 'routerboard-backup'
    # authentication method - 'http_token'
    auth-method: 'http_token'
    # token key - Keep it secret! (required)
    token: 'xxxxx'

My output:

pc@pc:$ php ./routerboard-backup.php rb:gitlab [2016-23-02 17:55:41] NOTICE: Group 'routerboard-backup' does not exist in repo. Creating new ... [2016-23-02 17:55:41] NOTICE: Group 'routerboard-backup' has been created successfully. [2016-23-02 17:55:41] NOTICE: Project 'rbackup' does not exist in repo. Creating new ... [2016-23-02 17:55:47] NOTICE: Project 'rbackup' has been created successfully. [2016-23-02 17:55:47] INFO: Action: Backup all routers from backup list to GitLab.

heximcz commented 8 years ago

Update please to the latest dev-master version. Here is new 'debug:' option in config.default.yml. Set it to 1 and check output.

Example output:

pc@pc:$ php ./routerboard-backup.php rb:gitlab
[2016-23-02 18:16:48] DEBUG: Array routerboard-backup
Array
(
)
[2016-23-02 18:16:48] NOTICE: Group 'routerboard-backup' does not exist in repo. Creating new ...
[2016-23-02 18:16:53] DEBUG: Array routerboard-backup
Array
(
    [0] => Array
        (
            [id] => 15
            [name] => routerboard-backup
            [path] => routerboard-backup
            [description] => Mikrotik RouterOS backup group.
            [avatar_url] => 
            [web_url] => http://git.my-domain.cz/groups/routerboard-backup
        )

)
...
...
...
pcdog commented 8 years ago

OK, I can't find anything obvious.

can I mail it to you? too much to censor in it....

heximcz commented 8 years ago

fixed #2 in 0eb88ed A big thank you to @pcdog