|
| 1 | +--- |
| 2 | +slug: gitea |
| 3 | +title: Gitea repositories and database |
| 4 | +sidebar_label: Gitea |
| 5 | +--- |
| 6 | +## Introduction |
| 7 | + |
| 8 | +Gitea stores the platform configuration (in the `values` repository), the workload catalog (in the `charts` repository), and user-created repositories. |
| 9 | + |
| 10 | +The recovery procedure described here uses the application-level backup of Gitea, i.e. using the `gitea dump` command line. This includes a current SQL dump of the database as well as all repositories and data. However, [Gitea documentation](https://docs.gitea.com/administration/backup-and-restore) recommends different methods for restoring the database, due to potential compatibility issues. |
| 11 | + |
| 12 | +A restore using this backup is advised if for some reason only Gitea has been affected by a severe operational event leading to data corruption or loss. It is also possible to restore the complete the database or single repositories. Be aware that after a partial restore there may be mismatches between the repository information and the database. |
| 13 | + |
| 14 | +## Retrieving backups |
| 15 | + |
| 16 | +When uploading and storing backups in the configured object storage bucket, there is also a local retention of the backups on a local volume for one day. After the local retention has expired, archives can be retrieved from the remote storage. |
| 17 | + |
| 18 | +Note that `rclone` is installed on the first time upload of a Gitea backup. If not present, it can be obtained from the releases page at https://github.com/rclone/rclone/releases/. Following variables such as `$BUCKET_NAME` or storage authentication are pre-configured in the container, so they do not need to be changed. |
| 19 | + |
| 20 | +```sh |
| 21 | +## |
| 22 | +## In the local terminal |
| 23 | +## |
| 24 | +kubectl exec -it -n gitea gitea-0 -- /bin/bash |
| 25 | + |
| 26 | +## |
| 27 | +## The following to be run in the remote container |
| 28 | +## |
| 29 | + |
| 30 | +## If needed, obtain and install Rclone |
| 31 | +mkdir -p /backup/.bin |
| 32 | +cd /backup/.bin |
| 33 | +curl -fsSL -o rclone.zip https://github.com/rclone/rclone/releases/download/v1.69.0/rclone-v1.69.0-linux-amd64.zip |
| 34 | +unzip -oj rclone.zip |
| 35 | +cd /backup |
| 36 | + |
| 37 | +## Optional, not required if backup is available locally |
| 38 | +.bin/rclone lsf gitea:/$BUCKET_NAME # List files |
| 39 | +.bin/rclone copy gitea:/$BUCKET_NAME/<backup-name>.tar.bz2 /backup/ # Retrieve file from remote |
| 40 | + |
| 41 | +## Extract the backup |
| 42 | +mkdir restore |
| 43 | +tar xvjf <backup-name>.tar.bz2 -C restore |
| 44 | +cd restore |
| 45 | +``` |
| 46 | + |
| 47 | +## Restoring a single repository |
| 48 | + |
| 49 | +Repositories are stored in the mounted container path `/data/git/gitea-repositories`, with the owning user or organization as a subdirectory. To restore a single repository, find the backup in the backup's `data/repos/<owner>` directory and copy it over to `/data/git/gitea-repositories/<owner>`. |
| 50 | + |
| 51 | +Note it is not recommended to restore the `otomi/values` repository with this method after restoring a full cluster. |
| 52 | + |
| 53 | +```sh |
| 54 | +## ... commands above to obtain and extract the backup |
| 55 | +cp -R repos/otomi/charts.git /data/git/gitea-repositories/otomi/ |
| 56 | +``` |
| 57 | + |
| 58 | +## Other assets |
| 59 | + |
| 60 | +Gitea file assets such as avatar images are to be found in the `data` directory of the backup. Similarly, they can be copied to the `/data/` subdirectory as needed, e.g. |
| 61 | + |
| 62 | +```sh |
| 63 | +## ... commands above to obtain and extract the backup |
| 64 | +cp -R data/avatars /data/ |
| 65 | +``` |
| 66 | + |
| 67 | +## Restoring the database |
| 68 | + |
| 69 | +For restoring the database of Gitea, please refer to the [platform database instructions](platform-databases.md). |
| 70 | + |
| 71 | +## Cleaning up |
| 72 | + |
| 73 | +Remove any extracted files from the local backup directory to free up space. They are not removed automatically. Only compressed backups with the `.tar.bz2` are cleaned up after one day. |
| 74 | + |
| 75 | +```sh |
| 76 | +cd /backup |
| 77 | +rm -R restore |
| 78 | +``` |
0 commit comments