diff options
| -rw-r--r-- | src/cgit/VERSION | 2 | ||||
| -rwxr-xr-x | src/cgit/bin/entrypoint.sh | 7 | ||||
| -rw-r--r-- | src/git-snapshot/Dockerfile | 7 | ||||
| -rw-r--r-- | src/git-snapshot/VERSION (renamed from src/gitsnapshot/VERSION) | 0 | ||||
| -rw-r--r-- | src/gitsnapshot/Dockerfile | 4 | ||||
| -rw-r--r-- | src/gitsnapshot/README.md | 3 | ||||
| -rw-r--r-- | src/gitsnapshot/gitbackup.sh | 114 |
7 files changed, 12 insertions, 125 deletions
diff --git a/src/cgit/VERSION b/src/cgit/VERSION index f9cece5..5c314e5 100644 --- a/src/cgit/VERSION +++ b/src/cgit/VERSION @@ -1 +1 @@ -v0.0.3 +v0.0.5 diff --git a/src/cgit/bin/entrypoint.sh b/src/cgit/bin/entrypoint.sh index 88ecded..80d3788 100755 --- a/src/cgit/bin/entrypoint.sh +++ b/src/cgit/bin/entrypoint.sh @@ -33,21 +33,22 @@ root-title=git.ofmax.li root-desc=grumpy software readme=:README.md + about-filter=/usr/lib/cgit/filters/about-formatting.sh source-filter=/usr/lib/cgit/filters/syntax-highlighting.py enable-index-links=1 -enable-commit-graph=1 enable-log-filecount=1 -enable-log-linecount=1 enable-commit-graph=1 +enable-index-owner=1 +enable-http-clone=1 +snapshots=tar.gz css=/cgit.css logo=/cgit.png virtual-root=/ robots=nofollow remove-suffix=1 - project-list=/var/lib/git/projects.list scan-path=/var/lib/git/repositories diff --git a/src/git-snapshot/Dockerfile b/src/git-snapshot/Dockerfile new file mode 100644 index 0000000..e2c23a5 --- /dev/null +++ b/src/git-snapshot/Dockerfile @@ -0,0 +1,7 @@ +ARG GIT_SNAPSHOT=0.0.1 +FROM registry.gitlab.com/grumps/grumpy-containers/base:v0.0.2 +ARG GIT_SNAPSHOT +SHELL ["/bin/bash", "-c"] +RUN install_deb python3-minimal python3-pip python3-setuptools python3-wheel \ + && pip3 install https://git.ofmax.li/git-snapshot/snapshot/git-snapshot-${GIT_SNAPSHOT}.tar.gz +WORKDIR "/var/lib/git" diff --git a/src/gitsnapshot/VERSION b/src/git-snapshot/VERSION index 45c7a58..45c7a58 100644 --- a/src/gitsnapshot/VERSION +++ b/src/git-snapshot/VERSION diff --git a/src/gitsnapshot/Dockerfile b/src/gitsnapshot/Dockerfile deleted file mode 100644 index 9df41d2..0000000 --- a/src/gitsnapshot/Dockerfile +++ /dev/null @@ -1,4 +0,0 @@ -FROM python:3-slim-buster -RUN pip install awscli && apt-get update -y && apt-get install -y git && apt-get clean -COPY gitbackup.sh /opt/app/gitbackup.sh -RUN chmod +x /opt/app/gitbackup.sh diff --git a/src/gitsnapshot/README.md b/src/gitsnapshot/README.md deleted file mode 100644 index 603674f..0000000 --- a/src/gitsnapshot/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# gitbackup - -creates bundle, uploads to s3, creates a checkpoint for next iteration diff --git a/src/gitsnapshot/gitbackup.sh b/src/gitsnapshot/gitbackup.sh deleted file mode 100644 index 47dee97..0000000 --- a/src/gitsnapshot/gitbackup.sh +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/env bash -AWS=/usr/local/bin/aws -basedir=$1 -bucket=$2 -repos_found=$basedir/*.git -num_repos_found=0 -completed=0 -backup_log="${basedir}/gitbackup-log" -mkdir -p "${backup_log}" -echo "starting for: $basedir" - -get_rev_list () { - : ' - generates a rev list since the last checkpoint. provides a blank - response if the checkpoint and the latest commit are one and the same - output: - "hash..hash2" - return - 0: successfully created a revlist - 1: no revlist created - ' - # last checkpoint in repo - local last_hash=$(git rev-list -n 1 --all) - # first commit in repo, or hash of last checkpoint - if ! $(git rev-list -n 1 CHECKPOINT &> /dev/null); - then - # first commit in repo - local checkpoint_hash=$(git rev-list --all | tail -n 1) - echo "${checkpoint_hash}" - return 0 - else - local checkpoint_hash=$(git rev-list -n 1 CHECKPOINT) - fi - - # if checkpoint and last hash are one and the same, offer nothing - if [ "${checkpoint_hash}" = "${last_hash}" ]; - then - # we provide nothing back - echo "" - return 1 - else - echo "${checkpoint_hash}..${last_hash}" - return 0 - fi -} - -create_bundle () { - : ' - Arguments: - arg1: rev_list in proper revlist format hash..hash2 - arg2: bundle name/path to create - creates a bundle for a given revlist - output: - none - returns: - 0: created bundle - 1: could not create bundle - ' - local rev_list=$1 - local bundle_path_name=$2 - if ! git bundle create "${bundle_path_name}" "${rev_list}" --all; - then - return 1 - else - return 0 - fi -} -for repo in $repos_found; -do - let num_repos_found++ || true - cd "${repo}" - repobase=$(basename $repo) - current_time=$(date +%s%N) - slug=${repobase%%.*} - tx_log="${backup_log}/${slug}.tx.log" - last_time=$(touch ${tx_log} && tail -n1 "${tx_log}" | cut -d " " -f 1) - last_time="${last_time:-0}" - bundle_name="${last_time}-${current_time}-${slug}.bundle" - bundle_tmp_path="/tmp/${bundle_name}" - s3_base="s3://${bucket}" - s3_uri="${s3_base}/${repobase}" - - rev_list=$(get_rev_list) - - if [ -z "${rev_list}" ]; - then - # we increase the counter, because not needing to update is ok - echo "${slug} has no new commits, no bundle generated" - let completed++ || true - continue - else - if ! $(create_bundle "${rev_list}" "${bundle_tmp_path}"); - then - echo "${bundle_name} failed to be created" >&2 - continue - fi - fi - if ! $AWS s3 cp "${bundle_tmp_path}" "${s3_uri}/${bundle_name}" - then - echo "$bundle_name failed to upload S3" >&2 - continue - else - # set checkpoint to the last hash in revlist - checkpoint="${rev_list:42}" - checkpoint=${checkpoint:-"${rev_list}"} - git tag -f CHECKPOINT "${checkpoint}" - # transaction log - echo "${current_time} ${rev_list}" >> "${tx_log}" - $AWS s3 cp "${tx_log}" "${s3_base}/logs/${slug}.tx.log" - fi - echo "${slug} backedup" - let completed++ || true -done -echo "${completed} of ${num_repos_found} repos backed up" |