Backing up your Gitea Docker Installation

TL;DR:
docker exec -u git -it -w /data/gitea/backup $(docker ps -qf "name=gitea_server_1") bash -c '/app/gitea/gitea dump -c /data/gitea/conf/app.ini'
The dump will be found in ./gitea/gitea/backup relative to directory containing your docker-compose.yml. You should create this “backup” directory first otherwise you will get a “no such directory” error.

 

Long version
How we arrived at the above command via Gitea’s docs:

docker exec -u <OS_USERNAME> -it -w <--tempdir> $(docker ps -qf "name=<NAME_OF_DOCKER_CONTAINER>") bash -c '/app/gitea/gitea dump -c </path/to/app.ini>'

Here’s what you should replace each <…> with, assuming you installed from Docker following the instructions here (note where docker mounts the container’s “data” folder is found under “services:”/”server:”/”volumes:”, it is likely the path ./gitea, relative to where your docker-compose.yml resides):

<OS_USERNAME>: Look inside gitea/conf/app.ini in the folder where docker mounts its “data” folder (./gitea/gitea/conf/app.ini relative to where your docker-compose.yml resides). It is the value matching RUN_USER, and this is usually git unless you changed it.

<–tempdir>: Leaving it as is will store it in /tmp in the container, which is not mounted to a local folder.  Create a “backup” directory ./gitea/gitea/backup relative to where your docker-compose.xml resides. Replace <–tempdir> with /data/gitea/backup, as this is a path referenced in the container.

<NAME_OF_DOCKER_CONTAINER>: run docker ps and note the NAME (last column) containing gitea.  This is usually “gitea_server_1”.

</path/to/app.ini>: This is a path referenced in the container, so it needs to use /data/gitea/conf/app.ini (i.e. this points to the local ./gitea/gitea/conf/app.ini relative to where your docker-compose.yml resides).

0 thoughts on “Backing up your Gitea Docker Installation”

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: