From charlesreid1

Via Gitea documentation: https://docs.gitea.io/en-us/command-line/

What Dump is For

Running the gitea dump command will dump the entire contents of Gitea's internal database and reposiitories to disk and zip it up.

The way I have described installing Gitea, it is important to run this command as the correct user, in this case the user git:

chmod 777 /temp/
cd /temp/
sudo -H -u git /www/gitea/bin/gitea dump --verbose

This will begin the backup process, which will take a few minutes.

Format of Output

The gitea dump dumps out the log files, and a zip file containing all of the repositories.

The directory structure is as follows:

The repositories folder contains all repositories.

Within the repositories folder, there is a folder for each user and organization.

Inside each user or organization folder, there is one folder for each repository that user owns.

The folders are called <reponame>.git and are the contents of the .git folder for that repository.

The .git folder can be used to get any and all info about the repository history. Most of the git utilities are designed to work with git directories in arbitrary locations, so that works to our advantage.

Logs

Goal is to extract log information from each repository. To do this, move into a repository directory and execute the git log command. Control formatting to make info easier to extract.

Formatting git log using preconfigured format

Git already provides several formats for dumping out the logs:

  • oneliner (commit and summary only)
  • short (commit, author, title)
  • medium (commit, author, date, title, commit message)
  • full (commit, author, committer, title, commit message)
  • email (from sha, from author, from date, subject, commit message)

Alternatively, you can customize the output format exactly by using output strings to control what text goes where. See below for examples.

Formatting git log using string

To use a custom string to format the output of git log, pass a format string to pretty:

git log --pretty=%H %ai %s

Formatting git log as JSON

There are many, many formatting stings to choose from, and you can get very fancy with the output. For example, this technique uses the pretty format to print each git commit item as a JSON in curlybrackets {}, and then wraps the resulting output in square brackets [] using perl.

git log \
    --pretty=format:'{%n  "commit": "%H",%n  "author": "%aN <%aE>",%n  "date": "%ad",%n  "message": "%f"%n},' \
    $@ | \
    perl -pe 'BEGIN{print "["}; END{print "]\n"}' | \
perl -pe 's/},]/}]/'

Via https://gist.github.com/textarcana/1306223

Flags