* backup git repo on every commit
@ 2009-10-12 13:41 Israel Garcia
2009-10-12 14:08 ` Christian Himpel
2009-10-12 14:15 ` Shawn O. Pearce
0 siblings, 2 replies; 14+ messages in thread
From: Israel Garcia @ 2009-10-12 13:41 UTC (permalink / raw)
To: git
Hi list, a simple question.
Which is the simplest way to backup a git repository after every commit?
--
Regards;
Israel Garcia
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: backup git repo on every commit
2009-10-12 13:41 backup git repo on every commit Israel Garcia
@ 2009-10-12 14:08 ` Christian Himpel
2009-10-12 14:15 ` Shawn O. Pearce
1 sibling, 0 replies; 14+ messages in thread
From: Christian Himpel @ 2009-10-12 14:08 UTC (permalink / raw)
To: Israel Garcia; +Cc: git
On Mon, Oct 12, 2009 at 08:41:15AM -0500, Israel Garcia wrote:
> Which is the simplest way to backup a git repository after every commit?
Using githooks(5) you can put a simple post-commit script in .git/hooks.
Maybe something like:
-->8--
#!/bin/sh
cp -a `pwd` `pwd`.`date +%s`
--8<--
Don't forget to make the script executable.
Regards,
chressie
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: backup git repo on every commit
2009-10-12 13:41 backup git repo on every commit Israel Garcia
2009-10-12 14:08 ` Christian Himpel
@ 2009-10-12 14:15 ` Shawn O. Pearce
2009-10-12 14:25 ` Israel Garcia
2009-10-12 18:35 ` Christian Himpel
1 sibling, 2 replies; 14+ messages in thread
From: Shawn O. Pearce @ 2009-10-12 14:15 UTC (permalink / raw)
To: Israel Garcia; +Cc: git
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.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: backup git repo on every commit
2009-10-12 14:15 ` Shawn O. Pearce
@ 2009-10-12 14:25 ` Israel Garcia
2009-10-12 14:30 ` Shawn O. Pearce
2009-10-12 18:35 ` Christian Himpel
1 sibling, 1 reply; 14+ messages in thread
From: Israel Garcia @ 2009-10-12 14:25 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git
Hi Shawn,
That's OK, but I want to backup my git repo locally because I don't
have another remote git server. Can you modify your post-commit code
to backup the repo to /backups/git folder instead of using another
external git repo?
thanks in advance.
regards
Israel.
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: backup git repo on every commit
2009-10-12 14:25 ` Israel Garcia
@ 2009-10-12 14:30 ` Shawn O. Pearce
2009-10-12 14:39 ` Israel Garcia
2009-10-13 16:43 ` Israel Garcia
0 siblings, 2 replies; 14+ messages in thread
From: Shawn O. Pearce @ 2009-10-12 14:30 UTC (permalink / raw)
To: Israel Garcia; +Cc: git
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.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: backup git repo on every commit
2009-10-12 14:30 ` Shawn O. Pearce
@ 2009-10-12 14:39 ` Israel Garcia
2009-10-13 16:43 ` Israel Garcia
1 sibling, 0 replies; 14+ messages in thread
From: Israel Garcia @ 2009-10-12 14:39 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git
On 10/12/09, Shawn O. Pearce <spearce@spearce.org> wrote:
> 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
Nice..:-)
>
> 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.
Yeap, but I use rsync to backup /backup folder on a remote server
every night. /backup folder other apps backups.
thanks Shawn.
regards
Israel.
>
>> 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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: backup git repo on every commit
2009-10-12 14:30 ` Shawn O. Pearce
2009-10-12 14:39 ` Israel Garcia
@ 2009-10-13 16:43 ` Israel Garcia
2009-10-13 17:49 ` Shawn O. Pearce
1 sibling, 1 reply; 14+ messages in thread
From: Israel Garcia @ 2009-10-13 16:43 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git
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:
> 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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: backup git repo on every commit
2009-10-13 16:43 ` Israel Garcia
@ 2009-10-13 17:49 ` Shawn O. Pearce
2009-10-13 18:08 ` Israel Garcia
2009-10-13 18:14 ` Israel Garcia
0 siblings, 2 replies; 14+ messages in thread
From: Shawn O. Pearce @ 2009-10-13 17:49 UTC (permalink / raw)
To: Israel Garcia; +Cc: git
Israel Garcia <igalvarez@gmail.com> wrote:
> 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?
Yes.
> The post-commit are execute on gitosis server or on the remote pc?
Actually, you need the post-update hook. post-commit doesn't run
on the gitosis server.
I suggested post-commit because I thought you were talking about
backing up your local working directory each time you called
"git commit". But since you are actually backing up every
"git push" you need to use the hooks invoked by that instead.
--
Shawn.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: backup git repo on every commit
2009-10-13 17:49 ` Shawn O. Pearce
@ 2009-10-13 18:08 ` Israel Garcia
2009-10-13 18:18 ` Shawn O. Pearce
2009-10-13 18:14 ` Israel Garcia
1 sibling, 1 reply; 14+ messages in thread
From: Israel Garcia @ 2009-10-13 18:08 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git
On 10/13/09, Shawn O. Pearce <spearce@spearce.org> wrote:
> Israel Garcia <igalvarez@gmail.com> wrote:
>> 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?
>
> Yes.
>
>> The post-commit are execute on gitosis server or on the remote pc?
>
> Actually, you need the post-update hook. post-commit doesn't run
> on the gitosis server.
>
> I suggested post-commit because I thought you were talking about
> backing up your local working directory each time you called
> "git commit". But since you are actually backing up every
> "git push" you need to use the hooks invoked by that instead.
Hi Shawn,
Thanks for your answer, could you please put here how you think
post-update file should be setup? Remember in my case I want to backup
every repo to /backups/git folder for example.
Thanks in advance.
regrads
Israel.
>
> --
> Shawn.
>
--
Regards;
Israel Garcia
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: backup git repo on every commit
2009-10-13 18:08 ` Israel Garcia
@ 2009-10-13 18:18 ` Shawn O. Pearce
0 siblings, 0 replies; 14+ messages in thread
From: Shawn O. Pearce @ 2009-10-13 18:18 UTC (permalink / raw)
To: Israel Garcia; +Cc: git
Israel Garcia <igalvarez@gmail.com> wrote:
> Thanks for your answer, could you please put here how you think
> post-update file should be setup? Remember in my case I want to backup
> every repo to /backups/git folder for example.
Exactly the same as that post-commit I mentioned, just call the
file .git/hooks/post-update instead.
--
Shawn.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: backup git repo on every commit
2009-10-13 17:49 ` Shawn O. Pearce
2009-10-13 18:08 ` Israel Garcia
@ 2009-10-13 18:14 ` Israel Garcia
2009-10-13 18:18 ` Shawn O. Pearce
1 sibling, 1 reply; 14+ messages in thread
From: Israel Garcia @ 2009-10-13 18:14 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git
BTW, is there any git-dump or git-backup command to do some kind of
backup I'm looking for?
regards,
Israel.
On 10/13/09, Shawn O. Pearce <spearce@spearce.org> wrote:
> Israel Garcia <igalvarez@gmail.com> wrote:
>> 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?
>
> Yes.
>
>> The post-commit are execute on gitosis server or on the remote pc?
>
> Actually, you need the post-update hook. post-commit doesn't run
> on the gitosis server.
>
> I suggested post-commit because I thought you were talking about
> backing up your local working directory each time you called
> "git commit". But since you are actually backing up every
> "git push" you need to use the hooks invoked by that instead.
>
> --
> Shawn.
>
--
Regards;
Israel Garcia
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: backup git repo on every commit
2009-10-13 18:14 ` Israel Garcia
@ 2009-10-13 18:18 ` Shawn O. Pearce
0 siblings, 0 replies; 14+ messages in thread
From: Shawn O. Pearce @ 2009-10-13 18:18 UTC (permalink / raw)
To: Israel Garcia; +Cc: git
Israel Garcia <igalvarez@gmail.com> wrote:
> BTW, is there any git-dump or git-backup command to do some kind of
> backup I'm looking for?
No, you backup git by making a clone. E.g. `git clone --bare`.
Since this leaves you with a directory, you need to then perhaps
use some sort of file combiner tool like tar or zip to produce a
single file for backup to tape.
You can incrementally update that backup clone using git push to
write into it, or you can just blow it away and recreate it each
time you make a backup.
One could also use `git bundle` to create backup file that had
everything packaged in one neat file, but this can be slightly
harder to work with since a bundle is not a git repository.
--
Shawn.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: backup git repo on every commit
2009-10-12 14:15 ` Shawn O. Pearce
2009-10-12 14:25 ` Israel Garcia
@ 2009-10-12 18:35 ` Christian Himpel
2009-10-12 18:37 ` Shawn O. Pearce
1 sibling, 1 reply; 14+ messages in thread
From: Christian Himpel @ 2009-10-12 18:35 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: Israel Garcia, git
On Mon, Oct 12, 2009 at 07:15:44AM -0700, Shawn O. Pearce wrote:
> Israel Garcia <igalvarez@gmail.com> wrote:
> 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
Since this is meant as a backup, is there also a sane way to push the
reflog entries as well? Or is it okay just to copy .git/logs to the
backup repository?
Thanks,
chressie
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: backup git repo on every commit
2009-10-12 18:35 ` Christian Himpel
@ 2009-10-12 18:37 ` Shawn O. Pearce
0 siblings, 0 replies; 14+ messages in thread
From: Shawn O. Pearce @ 2009-10-12 18:37 UTC (permalink / raw)
To: Christian Himpel; +Cc: Israel Garcia, git
Christian Himpel <chressie@googlemail.com> wrote:
> Since this is meant as a backup, is there also a sane way to push the
> reflog entries as well? Or is it okay just to copy .git/logs to the
> backup repository?
There isn't a way to transfer reflogs, but one could rsync them
over to the backup. Some records might be missing their SHA-1 in
the backup if that particular object wasn't pushed there, but the
reflog code is generally tolerant of those garbage records.
--
Shawn.
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2009-10-13 18:24 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-12 13:41 backup git repo on every commit Israel Garcia
2009-10-12 14:08 ` Christian Himpel
2009-10-12 14:15 ` Shawn O. Pearce
2009-10-12 14:25 ` Israel Garcia
2009-10-12 14:30 ` Shawn O. Pearce
2009-10-12 14:39 ` Israel Garcia
2009-10-13 16:43 ` Israel Garcia
2009-10-13 17:49 ` Shawn O. Pearce
2009-10-13 18:08 ` Israel Garcia
2009-10-13 18:18 ` Shawn O. Pearce
2009-10-13 18:14 ` Israel Garcia
2009-10-13 18:18 ` Shawn O. Pearce
2009-10-12 18:35 ` Christian Himpel
2009-10-12 18:37 ` Shawn O. Pearce
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).