|
| 1 | +--- |
| 2 | +date: "2021-09-02T16:00:00+08:00" |
| 3 | +title: "Upgrade from an old Gitea" |
| 4 | +slug: "upgrade-from-gitea" |
| 5 | +weight: 10 |
| 6 | +toc: false |
| 7 | +draft: false |
| 8 | +menu: |
| 9 | + sidebar: |
| 10 | + parent: "upgrade" |
| 11 | + name: "From Gitea" |
| 12 | + weight: 10 |
| 13 | + identifier: "upgrade-from-gitea" |
| 14 | +--- |
| 15 | + |
| 16 | +# Upgrade from an old Gitea |
| 17 | + |
| 18 | +**Table of Contents** |
| 19 | + |
| 20 | +{{< toc >}} |
| 21 | + |
| 22 | +To update Gitea, download a newer version, stop the old one, perform a backup, and run the new one. |
| 23 | +Every time a Gitea instance starts up, it checks whether a database migration should be run. |
| 24 | +If a database migration is required, Gitea will take some time to complete the upgrade and then serve. |
| 25 | + |
| 26 | +## Backup for downgrade |
| 27 | + |
| 28 | +Gitea keeps compatibility for patch versions whose first two fields are the same (`a.b.x` -> `a.b.y`), |
| 29 | +these patch versions can be upgraded and downgraded with the same database structure. |
| 30 | +Otherwise (`a.b.?` -> `a.c.?`), a newer Gitea version will upgrade the old database |
| 31 | +to a new structure that may differ from the old version. |
| 32 | + |
| 33 | +For example: |
| 34 | + |
| 35 | +| From | To | Result | |
| 36 | +| --- | --- | --- | |
| 37 | +| 1.4.0 | 1.4.1 | ✅ | |
| 38 | +| 1.4.1 | 1.4.0 | ⚠️ Not recommended, take your own risk! Although it may work if the database structure doesn't change, it's highly recommended to use a backup to downgrade. | |
| 39 | +| 1.4.x | 1.5.y | ✅ Database gets upgraded. You can upgrade from 1.4.x to the latest 1.5.y directly. | |
| 40 | +| 1.5.y | 1.4.x | ❌ Database already got upgraded and can not be used for an old Gitea, use a backup to downgrade. | |
| 41 | + |
| 42 | +**Since you can not run an old Gitea with an upgraded database, |
| 43 | +a backup should always be made before a database upgrade.** |
| 44 | + |
| 45 | +If you use Gitea in production, it's always highly recommended to make a backup before upgrade, |
| 46 | +even if the upgrade is between patch versions. |
| 47 | + |
| 48 | +Backup steps: |
| 49 | + |
| 50 | +* Stop Gitea instance |
| 51 | +* Backup database |
| 52 | +* Backup Gitea config |
| 53 | +* Backup Gitea data files in `APP_DATA_PATH` |
| 54 | +* Backup Gitea external storage (eg: S3/MinIO or other storages if used) |
| 55 | + |
| 56 | +If you are using cloud services or filesystems with snapshot feature, |
| 57 | +a snapshot for the Gitea data volume and related object storage is more convenient. |
| 58 | + |
| 59 | + |
| 60 | +## Upgrade with Docker |
| 61 | + |
| 62 | +* `docker pull` the latest Gitea release. |
| 63 | +* Stop the running instance, backup data. |
| 64 | +* Use `docker` or `docker-compose` to start the newer Gitea Docker container. |
| 65 | + |
| 66 | +## Upgrade from package |
| 67 | + |
| 68 | +* Stop the running instance, backup data. |
| 69 | +* Use your package manager to upgrade Gitea to the latest version. |
| 70 | +* Start the Gitea instance. |
| 71 | + |
| 72 | +## Upgrade from binary |
| 73 | + |
| 74 | +* Download the latest Gitea binary to a temporary directory. |
| 75 | +* Stop the running instance, backup data. |
| 76 | +* Replace the installed Gitea binary with the downloaded one. |
| 77 | +* Start the Gitea instance. |
| 78 | + |
| 79 | +## Take care about customized templates |
| 80 | + |
| 81 | +Gitea's template structure and variables may change between releases, if you are using customized templates, |
| 82 | +do pay attention if your templates are compatible with the Gitea you are using. |
| 83 | + |
| 84 | +If the customized templates don't match Gitea version, you may experience: |
| 85 | +`50x` server error, page components missing or malfunctioning, strange page layout, ... |
| 86 | +Remove or update the incompatible templates and Gitea web will work again. |
0 commit comments