Update GITEA on debian server: correct process

Hello fellow GITEA users,

Thanks in advance for your help.
I am not an expert at all on the subject so forgive me if the information provided is not clear enough or if the subject is not in the right category.

I installed GITEA from the repositories (not from a docker container) on a fresh debian 12 server.
I manage to make it run correctly and adress it to my domain. It is up and running smoothly for a couple of weeks, and I tested my repositories and process without any issues.

I am now trying to keep my GITEA server up to date.
I manage to install the debian packages for automatic security updates, and now I am trying to update GITEA (no need for auto update but I want to have a clean and clear process).

As I understand based on my readings of the documentation the main steps of the process could be:

  • stop gitea instance
  • backup the database (gitea dump)
  • update the binary file found in usr/local/bin
  • restart gitea instance

A detailed list of acitons for the average user would be:

  • log on to the machine
  • open a terminal
  • change to the user running gitea instances (git in most cases)
  • gitea shutdown
  • gitea dump
  • download the new binary file and replace it in usr/loca/bin
  • gitea restart

When I am trying to do this I am never able to stop my gitea process :

I am a little bit confused that then I type “gitea shutdown” the first thing I see is “Starting Gitea…” as of course it is already up and running.

I probably miss some basic understanding but I do not know excatly what.

Thanks for your time if you manage to read up to this point.

Have a great day,

When you installed from a Debian apt repository, you would keep it up to date with: sudo apt update && sudo apt upgrade

The method you referenced is for those who have done their own binary installation outside of host OS package management.

Despite being an apt fan, I went with a self-managed binary installation to better keep up with the pace of Gitea development. If you want more frequent updates than what Debian will provide, you may wish to do the same.

Thanks for your answer. My wording is obviously wrong.

I installed from gitea repository on github: Releases · go-gitea/gitea · GitHub

I installed from apt git maria-db nginx but not gitea.
So I am probably like yourself in “self-managed binary installation” and I also want to be able to follow correctly the versions to avoid security issues.

1 Like

You don’t appear to have built a systemd unit. You probably want to do that.

You don’t need to grunge the Gitea user. You can simply use sudo in front of your commands.

My process is as follows:

  1. SSH to server
  2. Update download URLs usng vim
  3. Download binary and checksum files using wget -i url.txt
  4. Disable Gitea vhost using a2dissite gitea.example.com.conf
  5. Test Apache config using apache2ctl -t
  6. Reload Apache using systemctl reload apache2.service
  7. Confirm reload using systemctl status apache2.service
  8. Stop Gitea usng systemctl stop gitea.service
  9. Backup database using mysqldump
  10. Install new binary using sudo rsync
  11. Change ownership and permissions using chown and chmod
  12. Start Gitea usng systemctl start gitea.service
  13. Enable Gitea vhost using a2ensite gitea.example.com.conf
  14. Test Apache config using apache2ctl -t
  15. Reload Apache using systemctl reload apache2.service
  16. Login to Gitea to make sure everything still works

Thank you.

Thanks to my installation documentation, I found back that I had already created a gitea.service file.

So now when I run your step 8. stop gitea.service it effecively stops my gitea instance.
Thats a first step for me!

As I am on nginx I am not sure that is the same commands as yours to use.

Instead of step 9. I was trying to use gitea dump but with no success.

In terminal I switched to git user : su git
Then I entered: ./gitea dump -c /etc/gitea/app.ini but it told me
“bash: ./gitea: Permission denied”

Sorry for still not being trivial to me.

Try not doing that. Try using sudo instead.

e.g. sudo ./gitea dump

I don’t know that you need to specify the config file when you are using the default file.

Virtual hosts are managed similarly on nginx as in Apache. Assuming that you have defined your vhosts one per config file, you will only need to remove the corresponding symlink from the sites-enabled folder and reload nginx. Replace the symlink and reload to re-enable the site.

Thanks again.

I tried “sudo ./gitea dump”
I got “./gitea command not found”

Strange

You specified a relative path to gitea. Were you in a directory where that would have been a valid path to your gitea binary?

please note that gitea will not execute as root (security protection) and thus you shouldn’t use sudo /path/to/gitea dump as this will attempt to execute as root and thus will fail

sudo -u git
or
sudo -u gitea

depending on the user the gitea executes as (git for gentoo, gitea for alpine)

1 Like