The whole process of gitea creation + operation + backup based on docker-compose

0.This blog information

Creation time: 2023-04-01Latest
modification time: 2023-04-01Official
reference document: https://gitea.io/en-us/

1.docker-compose file

Official document reference.
Note that I have mounted the tmp directory here for backup.

version: "3"

networks:
  gitea:
    external: false

services:
  server:
    image: gitea/gitea:1.19.0
    container_name: gitea
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - GITEA__database__DB_TYPE=mysql
      - GITEA__database__HOST=db:3306
      - GITEA__database__NAME=gitea
      - GITEA__database__USER=gitea
      - GITEA__database__PASSWD=gitea
      - TZ=Asia/Shanghai
    restart: always
    networks:
      - gitea
    volumes:
      - ./gitea:/data
      - ./gitea/tmp:/tmp
    ports:
      - "3000:3000"
      - "3422:22"
    depends_on:
      - db

  db:
    image: mysql:8
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=gitea
      - MYSQL_USER=gitea
      - MYSQL_PASSWORD=gitea
      - MYSQL_DATABASE=gitea
      - TZ=Asia/Shanghai
    networks:
      - gitea
    volumes:
      - ./mysql:/var/lib/mysql

2. Post-run status

Insert image description here
My directory is as follows
Insert image description here

3. Input some test data

Just create some accounts and then add some organizations and data
Insert image description here

4. Make a backup

Refer to the official document https://docs.gitea.io/en-us/backup-and-restore/
to back up the zip to the tmp directory
backup command

docker exec -u git -it -w /tmp 094341c71e68 bash -c '/usr/local/bin/gitea dump'

Insert image description here

5. Perform data restoration

5.1 only requires docker-compose.yml and gitea-dump-1680355388.zip

Insert image description here
5.2 docker compose up -d Start the container
Enter the gitea container and execute the following command

# open bash session in container
docker exec --user git -it 2a83b293548e bash
# unzip your backup file within the container
unzip gitea-dump-1610949662.zip
cd gitea-dump-1610949662
# restore the gitea data
mv data/* /data/gitea
# restore the repositories itself
mv repos/* /data/git/repositories/
# adjust file permissions
chown -R git:git /data
# Regenerate Git Hooks
/usr/local/bin/gitea -c '/data/gitea/conf/app.ini' admin regenerate hooks

5.3 Enter the mysql container

mysql --default-character-set=utf8mb4 -u$MYSQL_USER -p$MYSQL_PASSWORD $MYSQL_DATABASE <gitea-db.sql

5.4 Enter the gitea interface
Insert image description here
and check the three options below. At
Insert image description here
this time, the data will be restored to its previous state.

Insert image description here

Guess you like

Origin blog.csdn.net/weixin_42581660/article/details/129900310