Skip to main content

Version and backup a Git repository

Project description

What is this?

This is a small tool that does git fetch then writes down all ref updates in a SQLite3 database. It also creates refs to make sure no commit gets garbage collected.

What for?

If the remote repository gets force-pushed to, some commits might get lost. There will also be no evidence in the Git log that such destructive changes happened. It is also possible for a commit to be created but pushed much later, or branches can get renamed; none of this appears in the Git log either.

This tool will allow you to get a clear picture of what happened, never lose a commit, and quickly get a snapshot of a repository at a specific point in time. It is therefore more suitable for backups than a mirror.

Doesn’t the reflog do all that?

This is indeed similar to Git’s built-in reflog, except that the reflog isn’t aware of branch renames, and a branch’s reflog gets deleted with the branch.

It is also local, so you wouldn’t be able to read the reflog of a remote repository.

How to use

First, create a bare repo:

$ mkdir my-repo-backup && cd my-repo-backup
$ git init --bare

Set up one (or multiple) remotes to fetch from:

$ git remote add origin

Then simply run doublegit once in a while:

$ python3 /path/to/my-repo-backup

You can then query gitarchive.sqlite3 for branch updates or for the position of the branches at a given point in time.

Next steps?

I think it would be cool if this tool could record GitHub/GitLab/… API events too; things like issues/merge requests/comments.

It could also automatically backup all your starred repos.

This also doesn’t support tags yet.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for doublegit, version 1.2
Filename, size File type Python version Upload date Hashes
Filename, size doublegit-1.2-py2.py3-none-any.whl (6.4 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size doublegit-1.2.tar.gz (6.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page