How to Upgrade Gogs — Step by Step Guide

Gogs is a self-hosted git service written in Go. It's extremly fast and actually really easy to install and upgrade. This guide presents the steps to upgrade your running gogs instance to a newer version. The upgrade process bases on gogs binaries. The restore guide at the end will show you how to get back from lost lands in case the upgrade fails.

Gogs: Go Git Service

Choose the Release

The upgrade process starts at gogs' release page on GitHub. Choose the release you want to install and copy its download link.

Stop Running Gogs Service

SSH into your server and stop the gogs service, in case you run gogs as a service: service gogs stop.

Prepare Gogs Release on Your Server

Now login to the user which runs gogs. Create a temporary folder tmp and cd into it. Afterwards download the release by using wget and unzip the archive content. The following code illustrates the procedure using gogs release v0.5.8.

mkdir tmp  
cd tmp  
wget https://github.com/gogits/gogs/releases/download/v0.5.8/linux_amd64.zip  
unzip linux_amd64.zip  

When finishing the previous commands, you'll have a folder named gogs in your tmp directory.

Upgrade Gogs

You finished the upgrade preparation and we can do the actual upgrade for your gogs deployment. Before we go on: backup gogs! You can do that by copying the gogs folder to another directory. In case something goes wrong, you can go back to the current version and start fresh.

cp -R gogs gogs-backup  

For the upgrade process, first delete the old templates directory and then just copy all files from the new release folder to the gogs installation directory. Keep in mind, that you have to override folders, too. That requires to add the -a parameter to Unix cp command.

rm -r gogs/templates  
cp -a ~/tmp/gogs/. gogs  

If everything went smooth, that's it! Gogs now runs the new version and you just have to restart the gogs service with your admin user: service gogs start.

Restore Backup

In case the new release won't start, you can just go back to the previous instance. Remove the new installation and rename (or move) the backup instead to the previous production one.

rm -rf gogs  
mv gogs-backup gogs  

From here restart the server, report the issue to gogs GitHub and update gogs again once your errors got fixed.

Happy coding with your team! Let us know on Twitter @futurestud_io if this guide helped you or if you need help for your upgrade.

Explore the Library

Find interesting tutorials and solutions for your problems.