From charlesreid1

Revision as of 17:13, 14 February 2018 by Admin (talk | contribs)

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.

Use this gist to get a one-liner git log to json output: https://gist.github.com/textarcana/1306223

#!/usr/bin/env bash

# Use this one-liner to produce a JSON literal from the Git log:

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/},]/}]/'