From charlesreid1

No edit summary
No edit summary
Line 13: Line 13:
This will begin the backup process, which will take a few minutes.
This will begin the backup process, which will take a few minutes.


==Format==
==Format of Output==


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


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.
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
<pre>
#!/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/},]/}]/'
</pre>

Revision as of 17:08, 14 February 2018

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

Can dump the entire contents of Gitea's database to a zip directory using the gitea dump command.

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