# Using git for file archival/backup purposes - deletion strategy

4 messages from 2007-12-26 to 2007-12-27. Participants: Martin Langhoff, Johannes Sixt, Charles Bailey.
Thread: https://gitlist.dev/t/11405

## Martin Langhoff, 2007-12-26 22:43

Subject: Using git for file archival/backup purposes - deletion strategy
Message-ID: <46a038f90712261443t6aa0cd76u46d8ae88fc7c1eba@mail.gmail.com>
URL: https://gitlist.dev/e/46a038f90712261443t6aa0cd76u46d8ae88fc7c1eba%40mail.gmail.com

```
Hi list!

I am drafting a tool to use GIT as a behind-the-scenes archival/backup
tool for web applications. There's been countless threads covering
generic file archival, discussing /etc and homedirs, so I am pretty
comfortable with the mechanics and the whole idea. This is a fairly
narrow use, where the web apps are reasonable well behaved -- most
(all?) of the caveats in ~ and /etc archival seem to be under control.

What I am not 100% clear on is the "old history" deletion strategy.
The history will be *strictly* linear, so my intention is to keep the
last N commits, by overriding the parent of the Nth commit that git
log lists with a "shallow" entry in $GIT_DIR/shallow as documented in
Documentation/technical/shallow.txt , and call gc after that.

Is that the correct way to "forget" old history? Searching high and
low in the list, I fail to find a definitive answer. Shallow and
grafts entries are discussed as ways of doing this, but I can't find a
"correct" way of doing this.

BTW I've just done a git clone --depth 10 ~/src/git and while I do get
a clearly "shallow" checkout, with a tiny .git/objects directory, I
can't find any file called shallow, or grafts. .git/config doesn't say
anything either, and alternates is empty. I frankly cannot tell how
git recognizes it as a shallow repo.

Ah! Local clones won't honour --depth!. A clone from git.kernel.org
does get its .git/shallow file.

So the question is: is it safe (and enough) to add the SHA1 to the
.git/shallow file and call git gc? Is there a better way?

cheers,


m

```

## Johannes Sixt, 2007-12-27 09:18

Subject: Re: Using git for file archival/backup purposes - deletion strategy
Message-ID: <47736DE5.40509@viscovery.net>
URL: https://gitlist.dev/e/47736DE5.40509%40viscovery.net
In-Reply-To: <46a038f90712261443t6aa0cd76u46d8ae88fc7c1eba@mail.gmail.com>

```
Martin Langhoff schrieb:
> What I am not 100% clear on is the "old history" deletion strategy.
> The history will be *strictly* linear, so my intention is to keep the
> last N commits, by overriding the parent of the Nth commit that git
> log lists with a "shallow" entry in $GIT_DIR/shallow as documented in
> Documentation/technical/shallow.txt , and call gc after that.
> 
> Is that the correct way to "forget" old history? Searching high and
> low in the list, I fail to find a definitive answer. Shallow and
> grafts entries are discussed as ways of doing this, but I can't find a
> "correct" way of doing this.

I'm doing something like this. Basically:

   git rev-parse "HEAD~$N" > .git/info/grafts
   git filter-branch -f HEAD

If you omit filter-branch, then a repack -a -d will corrupt the repository
(I think) unless you keep the grafts file with it and in all its clones
forever.

-- Hannes

```

## Charles Bailey, 2007-12-27 16:36

Subject: Re: Using git for file archival/backup purposes - deletion strategy
Message-ID: <4773D498.8040204@hashpling.org>
URL: https://gitlist.dev/e/4773D498.8040204%40hashpling.org
In-Reply-To: <46a038f90712261443t6aa0cd76u46d8ae88fc7c1eba@mail.gmail.com>

```
Martin Langhoff wrote:
> Ah! Local clones won't honour --depth!. A clone from git.kernel.org
> does get its .git/shallow file.

This should be fixed in git v1.5.4-rc0 and later.  For reference 
what version of git are you using?

Charles.

```

## Martin Langhoff, 2007-12-27 22:08

Subject: Re: Using git for file archival/backup purposes - deletion strategy
Message-ID: <46a038f90712271408k7763d60ai93491f59c75d0e35@mail.gmail.com>
URL: https://gitlist.dev/e/46a038f90712271408k7763d60ai93491f59c75d0e35%40mail.gmail.com
In-Reply-To: <4773D498.8040204@hashpling.org>

```
On Dec 28, 2007 5:36 AM, Charles Bailey <charles@hashpling.org> wrote:
> Martin Langhoff wrote:
> > Ah! Local clones won't honour --depth!. A clone from git.kernel.org
> > does get its .git/shallow file.
>
> This should be fixed in git v1.5.4-rc0 and later.  For reference
> what version of git are you using?

Good point. I was using a 1.5.3xx. I can confirm it's fixed with
1.5.4.rc1.1136.g2794f - I get the shallow clone I expected.

cheers!


m

```
