[solved] URL to repository wrong after restoration from Backup

Hello,
i have restored gitea from a backup. everything seems to be fine but if i want to view an existing repository by clicking URLs, they seem to be wrong (only the hostname instead of gitea.domain/username/reponame.git). If i enter the URL by hand, i can view the repository and the files within. So they are existing, it is just the wrong URL.

What could I be missing? I tried to set the ROOT_URL in App ini but it wont work.
Creating new repositories works, I can access them as usual.

Thanks for your help in advance

My app.ini:

APP_NAME = Gitea: Git with a cup of tea
RUN_USER = git
RUN_MODE = prod

[oauth2]
JWT_SECRET = kjasdölgkjsöldkfjg

[security]
INTERNAL_TOKEN = eyJhbGciOblablablabkaksjdflkajsdfLnHbNlDw3jTmFgBl9xrb4JEl30
INSTALL_LOCK = true
SECRET_KEY = Ci73OlXQksJDRknQKQWmncgruymNyFdzS4V4OndrYWwlTzcIpEcPzCxonxyDgqHD

[database]
DB_TYPE = mysql
HOST = 127.0.0.1:3306
NAME = gitea_db
USER = gitea
PASSWD = mysecret
SSL_MODE = disable
CHARSET = utf8mb4
PATH = /var/lib/gitea/data/gitea.db

[repository]
ROOT = /home/git/gitea-repositories

[server]
HTTP_ADDR = 127.0.0.1
REDIRECT_OTHER_PORT = true
PROTOCOL = HTTP
CERT_FILE = /etc/letsencrypt/gitea.my-domain.de/ecc/cert.pem
KEY_FILE = /etc/letsencrypt/gitea.my-domain.de/ecc/key.pem
SSH_DOMAIN = gitea.my-domain.de
DOMAIN = gitea.my-domain.de
HTTP_PORT = 3000
ROOT_URL = new-users-2-urls-only
DISABLE_SSH = false
SSH_PORT = 22
LFS_START_SERVER = true
LFS_CONTENT_PATH = /var/lib/gitea/data/lfs
LFS_JWT_SECRET = 97naiY2zdhDIb2tgah6Xc9ACnDbvNHOtoQHxW71eUTg
OFFLINE_MODE = false
ROOT_URL = new-users-2-urls-only

[mailer]
ENABLED = false

[service]
REGISTER_EMAIL_CONFIRM = false
ENABLE_NOTIFY_MAIL = false
DISABLE_REGISTRATION = true
ALLOW_ONLY_EXTERNAL_REGISTRATION = false
ENABLE_CAPTCHA = false
REQUIRE_SIGNIN_VIEW = true
DEFAULT_KEEP_EMAIL_PRIVATE = false
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
DEFAULT_ENABLE_TIMETRACKING = true
NO_REPLY_ADDRESS = noreply.localhost

[picture]
DISABLE_GRAVATAR = false
ENABLE_FEDERATED_AVATAR = true

[openid]
ENABLE_OPENID_SIGNIN = false
ENABLE_OPENID_SIGNUP = false

[session]
PROVIDER = file

[log]
MODE = file
LEVEL = info
ROOT_PATH = /var/lib/gitea/log

1 Like

Hello,

I did experience the same issue when restoring an older gitea (1.11.0) to a more recent one 1.12.3
The repositories url were missing the domain part.

The cause of the issue seems to be the empty field owner_name in the repository table.
This field is not in the db dump, it was probably added in newer gitea versions.

You can fix the url issue by populating this field in the repository table.

If you open your sqlite db, you can get a list of user id and username with

select id, lower_name from user;

then update the repository table replacing USERNAME and USERID with the values from the above query

update repository set owner_name='USERNAME' where owner_id=USERID

After this for me the repository urls where working and contained the domain part

Regards
Olivier

1 Like

THANK YOU FOR THIS POST!

I’ve been trying to solve this a few weeks now after doing an update…

I’m using MariaDB, and it looks like this:

MariaDB [spacecruft]> select owner_name, owner_id FROM repository;
+------------+----------+
| owner_name | owner_id |
+------------+----------+
| NULL       |        6 |
| NULL       |        6 |
| NULL       |        6 |
 ...
27 rows in set (0.001 sec)

In the other table:

MariaDB [spacecruft]> select id, lower_name from user;
+----+------------+
| id | lower_name |
+----+------------+
| 14 | cv         |
|  3 | jebba      |
| 20 | lab        |
| 23 | ml1        |
| 17 | monitor    |
|  6 | spacecruft |
| 26 | wut        |
+----+------------+
7 rows in set (0.001 sec)

So the fix, to be done for each id (thankfully just a few here!):

update repository set owner_name='spacecruft' where owner_id=6

And now everything is working again! THANK YOU @Olivier and @vtmb!