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

Re: backup git repo on every commit

From
Israel Garcia <igalvarez@gmail.com>
Date
Oct 13, 2009, 16:43 UTC
Message-ID
<194a2c240910130943j40c12902o760e463e7a8ce8fa@mail.gmail.com>
In-Reply-To
<20091012143043.GJ9261@spearce.org>
Hi Shawn,

Sorry to ask again, but I'm a little confuse about how git work in my case. I use gitosis on a server where I have all repos (/usr/local/git/repositories/), so different people clone their repos on their computers. What I want is to backup, on gitosis server, all repos in /backups/git/repositories/ after every commit. So, my questions are:

Do I have to run these two comands on tha gitosis server? Or on a
remote computer?
  git --git-dir=/backup/project.git init
  git remote add --mirror backup /backup/project.git
The post-commit are execute on gitosis server or on the remote pc?
I'm completely new using git so I'm a little confuse.. sorry for asking again.

thanks a lot. regards Israel. On 10/12/09, Shawn O. Pearce <spearce@spearce.org> wrote:

Show 35 quoted lines
> Israel Garcia <igalvarez@gmail.com> wrote:
>> That's OK, but I want to backup my git repo locally
>
> Just change the path of the backup remote (that final argument to
> git remote add) to point to the local directory.
>
> Though I guess you would also need to run git init there, e.g.:
>
>   git --git-dir=/backup/project.git init
>   git remote add --mirror backup /backup/project.git
>
>   # and create the hook as below
>
> Of course, backup to another folder on the same disk isn't a backup
> at all, the disk can still fail and lose both repositories.
>
>> On 10/12/09, Shawn O. Pearce <spearce@spearce.org> wrote:
>> > Israel Garcia <igalvarez@gmail.com> wrote:
>> >> Which is the simplest  way to backup a git repository after every
>> >> commit?
>> >
>> > Add a commit hook to push to another location, e.g.:
>> >
>> >   git remote add --mirror backup you@another.host:path/to/backup.git
>> >
>> >   cat >.git/hooks/post-commit
>> >   #!/bin/sh
>> >   git push backup
>> >   ^D
>> >
>> >   chmod a+x .git/hooks/post-commit
>
> --
> Shawn.
>
-- 
Regards;
Israel Garcia
Previous: Israel GarciaNext: Shawn O. Pearce
Message 7 of 14 in “backup git repo on every commit”
  1. Israel GarciaOct 12, 2009
  2. Christian HimpelOct 12, 2009
  3. Shawn O. PearceOct 12, 2009
  4. Israel GarciaOct 12, 2009
  5. Shawn O. PearceOct 12, 2009
  6. Israel GarciaOct 12, 2009
  7. Israel GarciaOct 13, 2009
  8. Shawn O. PearceOct 13, 2009
  9. Israel GarciaOct 13, 2009
  10. Shawn O. PearceOct 13, 2009
  11. Israel GarciaOct 13, 2009
  12. Shawn O. PearceOct 13, 2009
  13. Christian HimpelOct 12, 2009
  14. Shawn O. PearceOct 12, 2009

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.