go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
45.45k stars 5.52k forks source link

Proposal: Import/Migration of all repos in your data-dir should work with a single cli or web-command #4474

Open Cyber1000 opened 6 years ago

Cyber1000 commented 6 years ago

Edit :exclamation: : Changing the title, since there is just one point left, my proposal to imports of local repos can be read from starting here: https://github.com/go-gitea/gitea/issues/4474#issuecomment-583788178


Description

Thanks, Cyber1000

Cyber1000 commented 6 years ago

I've done some research and came to this solution (base is a docker gitea configuration):

  1. Backing up my volume with all the configs (except repositories), backing up my repositories and dumping the mysql-database should include everything. So I may go with this ...
  2. I came to a solution. Having a script with following content:

!/bin/bash

echo "#File is created automatically, don't change things in here" > ./data/gitea/conf/app.ini cat ./data/gitea/conf/app.part.ini>>./data/gitea/conf/app.ini cat ./data/gitea/conf/app.pwd.ini>>./data/gitea/conf/app.ini docker-compose up -d

app.part.ini is everything except password app.pwd.ini is:

[database] PASSWD = xxxxxx

On merging, two database-sections are in the resulting file, but that doesn't matter. Solution could be better (I have to think to start this script instead of a simple docker-compose up, everytime I change something), but for my purposes it's sufficent.

  1. This is somehow my mainpoint for now, since I have a handful of small repos. For now I've turned on IMPORT_LOCAL_PATHS and I'm migrating one by one directly from filesystem. But it's a little bit anoying. A think it would be nothing more than to traverse the directory of a user (or all directories in repositories?), check if the path is entered in database and if it is not -> internally execute the Migrate-Command and pass the name of the found folder, path and user as arguments. More or less, I don't have the time to go deeper, at least for now,

Thanks, Cyber1000

Cyber1000 commented 4 years ago

Just a follow up, cause I did a cleanup to my configuration:

  1. The approach I used is just fine, with backing up the mysql-db and my repo separately without gitea dump
  2. I have my own template in ./data/etc/templates/app.ini I can put environment variables in there (more can be found here https://github.com/go-gitea/gitea/blob/70d2244e49e60e11877f850803d33ef1e3900fa6/docker/root/etc/s6/gitea/setup):
    [database]
    DB_TYPE  = mysql
    HOST     = database
    NAME     = gitea
    USER     = $DB_USER
    PASSWD   = $DB_PASSWD

I didn't make everything variable (like the database), since I just wanted to mask the password/user, and some other small things. My docker-compose.yaml (just relevant parts):

environment:
      - USER_UID=1000
      - USER_GID=1000
      - DB_USER=${DB_USER}
      - DB_PASSWD=${DB_PASSWD}
   volumes:
      - ./data/etc/templates/app.ini:/etc/templates/app.ini
Cyber1000 commented 4 years ago

Changing title of this issue, since the other 2 points are well working.

An easy import of all local stored repos would be nice on first start (or by triggering it) either from webui or from cli (or both)