Migration from 1.2 to 1.16.8

Hi,
I have been using Gitea service for 5 years. The gitea version is too old, however, I have lots of repo there. How can I to the migration simply?

Bonjour,

You first need to backup your instance properly and create a test environment restored from the backup (see here for an example involving a binary installation with a postgreql database).

You then need to upgrade from:

  • 1.2.current (the version you are running) to v1.2.3 and then,
  • v1.3.3
  • v1.4.3
  • v1.5.3
  • v1.6.4

And verify at each step that it works using the Gitea web interface. If you get there and everything seems ok, you can then follow the instructions in the following guide and upgrade to 1.16.8 directly.

I’d be very interested to know how it goes, please keep this topic updated with your progress :heart:

Cheers

Step #1 is BACKUP!
gitea dump will do for this, and keep a copy of the gitea.exe that works with this backup.

If things go wrong you can always go back and try again

2 Likes

Hi guys,
Thanks for the reply.
I will try it, but the step seems too crazy…
My original idea is to create a new gitea server, and re-create all account (not too many, 20 people), then gitea seems having a choice to move an outside repo into it with ‘access token’. It says including all data, such as tickets, wiki, and so on.
Not sure if the way is possible.

Sincrely

I’m quite sure there is no easier or faster way. Migrating users and projects one by one will take longer and it is likely you will miss something and loose data.

Hi,
I tried to use gitea dump, but got some errors.
=== error log ===
➜ gitea ./gitea dump -c custom/conf/app.ini
2022/06/06 12:59:07 Creating tmp work dir: /tmp/gitea-dump-451175765
2022/06/06 12:59:07 Dumping local repositories…/home/git/repositories
2022/06/06 13:03:49 Dumping database…
2022/06/06 13:03:50 Packing dump files…
2022/06/06 13:03:50 Packing data directory…data
2022/06/06 13:03:51 Failed to include data directory: open /home/git/gitea/data/tmp/local-repo/20/utils/gpsd/devtools/gps: no such file or directory

My gitea version is as follows.
Gitea version 1.2.0+rc1-6-g002fa73 built with: bindata, sqlite

Does anyone have ideas? Thanks.

Is the files really exist /home/git/gitea/data/tmp/local-repo/20/utils/gpsd/devtools/gps ?

All files below /home/git/gitea/data/tmp could be ignored if Gitea stopped.

Hi Iunny,
the files don’t exist actually. I don’t know why it read this.
Can it be removed automatically if I restart gitea or the server?

Sincerely

You will use the backup to try the upgrade without risking damaging your production, right? In that case you can simply do a file system backup and restore it in a test environment (see how it was done with docker and postgresql for an example). There is no need for gitea dump in this case.

Good idea, I will try it.

1 Like

Hi,
Let me update my progress.

  1. I have a gitea server with version 1.2.0-rc1 and sqlite3 and it’s not docker.
  2. I used ‘tar’ to backup everything, and I guess the most important folders are repos and gitea.
  3. I used docker to install gitea 1.2.3 and go to install page to build a clean gitea service.
    ex: sudo docker run -d --name=gitea -p 22:22 -p 3000:3000 -v /home/ttt710516/gitea:/data gitea/gitea:1.2.3
  4. Then I untar and copy the needed files into /home/ttt710516/gitea. Now it works.
  5. I change gitea version 1.2.3 → 1.4.3 → 1.5.3 → 1.6.4, even to 1.7.6, it still works. I think each time the gitea.db will change a little bit.
  6. I can’t do the same thing to 1.8.X, it seems a known bug?
  7. Then I go back to 1.6.4 and upgrade to 1.16.X directly, the docker can’t start correctly.
    the error log is as follows.
    ====
    ➜ gitea sudo docker logs gitea
    Server listening on :: port 22.
    Server listening on 0.0.0.0 port 22.
    2022/06/07 07:01:12 cmd/web.go:102:runWeb() [I] Starting Gitea on PID: 17
    2022/06/07 07:01:12 cmd/web.go:150:runWeb() [I] Global init
    2022/06/07 07:01:12 routers/init.go:107:GlobalInitInstalled() [I] Git Version: 2.30.3, Wire Protocol Version 2 Enabled
    2022/06/07 07:01:12 routers/init.go:110:GlobalInitInstalled() [I] AppPath: /usr/local/bin/gitea
    2022/06/07 07:01:12 routers/init.go:111:GlobalInitInstalled() [I] AppWorkPath: /app/gitea
    2022/06/07 07:01:12 routers/init.go:112:GlobalInitInstalled() [I] Custom path: /data/gitea
    2022/06/07 07:01:12 routers/init.go:113:GlobalInitInstalled() [I] Log path: /data/gitea/log
    2022/06/07 07:01:12 routers/init.go:114:GlobalInitInstalled() [I] Configuration file: /data/gitea/conf/app.ini
    2022/06/07 07:01:12 routers/init.go:115:GlobalInitInstalled() [I] Run Mode: Prod

Not sure what happened?

Sincerely

1 Like

You seem to be doing good progress :+1: A few comments:

  • Do not attempt to use docker, use the binary installation on a new virtual machine or a new machine. The directory layout of docker and your binary installation are probably different and this may have an impact on the upgrades.
  • As recommended here stop at 1.6.4. And then go directly to 1.16.8. As you experienced, you might run into issues that are not worth solving.
  • You write “1.2.3 → 1.4.3 → 1.5.3 → 1.6.4” and it is missing 1.3.3: make sure you included it.

If you run into a problem, you should show the commands you type and their output, upload the logs somewhere. When you write “the docker can’t start correctly”, it is not possible for me to figure out what it means otherwise. If, instead, you copy/paste the error that you see, it is a useful information that I can understand.

I’d like to say this is a very interesting upgrade because it is an unusually old Gitea installation. I’m convinced it can be upgraded successfully without loosing any data and that it can be done simply. If you want me to take a look, feel free to upload the tarbal at this secure location forgefriends

Hi Dachary,
I upload the log to your free space.
I redo the following procedure for the log.

  1. I use binary gitea, not docker version
  2. I created a clean gitea environment with v1.2.3 and copy the needed files into it.
    2.1 I copied gitea.db, repos, and attachments. Not sure if I need to copy avatars, indexers, and sessions. finally, I didn’t copy them, I think they will be re-generated, so they are not important.
  3. I re-run gitea 1.2.3 → 1.3.3 → 1.4.3 → 1.5.3 → 1.6.4, it seems working.
  4. Now, I run gitea 1.16.8 directly and got the log. It seems DB issues.

If anything I missed, please let me know. Thanks.

Sincerely

It is just because some repositories are missing and it fails a migration. The error log does not say which ones but you can activate debugging to know more. Once I have this information I can tell you how to workaround it.

2022/06/07 20:22:23 routers/common/db.go:33:InitDBEngine() [E] ORM engine initialization attempt #1/10 failed. Error: migrate: migration[82]: hot fix for wrong release sha1 on release table failed: no such file or directory

Hi dachry,
Thanks for your support.
I tried to copy all repos into the folder. Now, it seems working.
I will continue investigating it before I do real migration.
So 1.2.3 → 1.3.3 → 1.4.3 → 1.5.3 → 1.6.4 → 1.16.8, it seems a correct way.
I will keep updating if having any issues.

Thanks, everyone.

Sincerely

1 Like

Good to know :slight_smile: Did you run the doctor to verify the sanity of the migrated Gitea instance?

Did you get a chance to run gitea doctor and verify all is well?

Hi Dachary,
I may have no time to try this. Sorry for that. In the beginning, I tried the doctor, but it has some port mapping issue. So finally I gave up.
The result I can say is that basically I can succeed to upgrade from 1.2.0 → 1.2.3 → 1.3.3 → 1.4.3 → 1.5.3 → 1.6.4 → 1.16.8 by using binary giteas. It still has some issues, but seems working well 99%.

Hope the result is helpful.

Sincerely

2 Likes