git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: File versioning based on shallow Git repositories?

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Apr 12, 2018, 18:47 UTC
Message-ID
<87d0z4b6ti.fsf@evledraar.gmail.com>
In-Reply-To
<hbf.20180412fvfi@bombur.uio.no>
On Thu, Apr 12 2018, Hallvard Breien Furuseth wrote:
Show 21 quoted lines
> Can I use a shallow Git repo for file versioning, and regularly purge
> history older than e.g. 2 weeks?  Purged data MUST NOT be recoverable.
>
> Or is there a backup tool based on shallow Git cloning which does this?
> Push/pull to another shallow repo would be nice but is not required.
> The files are text files up to 1/4 Gb, usually with few changes.
>
>
> If using Git - I see "git fetch --depth" can shorten history now.
> How do I do that without 'fetch', in the origin repo?
> Also Documentation/technical/shallow.txt describes some caveats, I'm
> not sure how relevant they are.
>
> To purge old data -
>   git config core.logallrefupdates false
>   git gc --prune=now --aggressive
> Anything else?
>
> I'm guessing that without --aggressive, some expired info might be
> deduced from studying the packing of the remaining objects.  Don't
> know if we'll be required to be that paranoid.

The shallow feature is not for this use-case, but there's a much easier solution that I've used for exactly this use-case, e.g. taking backups of SQL dumps that delta-compress well, and then throwing out old backups.

You:
1. Create a backup.git repo
2. Each time you make a backup, checkout a new orphan branch, see "git
   checkout --orphan"
3. You copy the files over, commit them, "git log" at this point shows
   one commit no matter if you've done this before.
4. You create a tag for this backup, e.g. one named after the current
   time, delete the branch.
5. You then have a retention period for the tags, e.g. only keep the
   last 30 tags if you do daily backups for 30 days of backups.

Then as soon as you delete the tags the old commit will be unreferenced, and you can make git-gc delete the data.

You'll still be able to `git diff` between tags, even though they have unrelated histories, and the files will still delta-compress.

Previous: Hallvard Breien FurusethNext: Hallvard Breien Furuseth
Message 2 of 9 in “File versioning based on shallow Git repositories?”
  1. Hallvard Breien FurusethApr 12, 2018
  2. Ævar Arnfjörð BjarmasonApr 12, 2018
  3. Hallvard Breien FurusethApr 12, 2018
  4. Ævar Arnfjörð BjarmasonApr 12, 2018
  5. Rafael AscensaoApr 12, 2018
  6. Hallvard Breien FurusethApr 12, 2018
  7. Jakub NarebskiApr 13, 2018
  8. Johannes SchindelinApr 13, 2018
  9. Jakub NarebskiApr 13, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.