{"thread":{"id":"21212","subject":"backup git repo on every commit","startedAt":"2009-10-12T13:41:15Z","lastAt":"2009-10-13T18:18:43Z","messageCount":14,"participants":["Israel Garcia","Christian Himpel","Shawn O. Pearce"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"124694","messageId":"194a2c240910120641sccf0e55xef4226269df78864@mail.gmail.com","threadId":"21212","inReplyTo":null,"subject":"backup git repo on every commit","fromName":"Israel Garcia","fromEmail":"igalvarez@gmail.com","sentAt":"2009-10-12T13:41:15Z","receivedAt":"2009-10-12T13:41:15Z","isPatch":false,"sender":{"key":"igalvarez@gmail.com","avatar":"https://gravatar.com/avatar/8ccdadcbfb98c0cb0940523de930580bd60319c2802d3dbfce9aeaa7c778116c?d=mp&s=160"},"body":"Hi list, a simple question.\n\nWhich is the simplest  way to backup a git repository after every commit?\n\n-- \nRegards;\nIsrael Garcia\n"},{"id":"124695","messageId":"20091012140838.GB29984@lamagra.informatik.uni-ulm.de","threadId":"21212","inReplyTo":"194a2c240910120641sccf0e55xef4226269df78864@mail.gmail.com","subject":"Re: backup git repo on every commit","fromName":"Christian Himpel","fromEmail":"chressie@googlemail.com","sentAt":"2009-10-12T14:08:38Z","receivedAt":"2009-10-12T14:08:38Z","isPatch":false,"sender":{"key":"chressie@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/227883?v=4"},"body":"On Mon, Oct 12, 2009 at 08:41:15AM -0500, Israel Garcia wrote:\n> Which is the simplest  way to backup a git repository after every commit?\n\nUsing githooks(5) you can put a simple post-commit script in .git/hooks.\n\nMaybe something like:\n-->8--\n#!/bin/sh\n\ncp -a `pwd` `pwd`.`date +%s`\n--8<--\n\nDon't forget to make the script executable.\n\nRegards,\nchressie\n"},{"id":"124697","messageId":"20091012141544.GF9261@spearce.org","threadId":"21212","inReplyTo":"194a2c240910120641sccf0e55xef4226269df78864@mail.gmail.com","subject":"Re: backup git repo on every commit","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-10-12T14:15:44Z","receivedAt":"2009-10-12T14:15:44Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Israel Garcia <igalvarez@gmail.com> wrote:\n> Which is the simplest  way to backup a git repository after every commit?\n\nAdd a commit hook to push to another location, e.g.:\n\n  git remote add --mirror backup you@another.host:path/to/backup.git\n\n  cat >.git/hooks/post-commit\n  #!/bin/sh\n  git push backup\n  ^D\n\n  chmod a+x .git/hooks/post-commit\n\n-- \nShawn.\n"},{"id":"124701","messageId":"194a2c240910120725u72cdb588p3c66bc730e6953d@mail.gmail.com","threadId":"21212","inReplyTo":"20091012141544.GF9261@spearce.org","subject":"Re: backup git repo on every commit","fromName":"Israel Garcia","fromEmail":"igalvarez@gmail.com","sentAt":"2009-10-12T14:25:44Z","receivedAt":"2009-10-12T14:25:44Z","isPatch":false,"sender":{"key":"igalvarez@gmail.com","avatar":"https://gravatar.com/avatar/8ccdadcbfb98c0cb0940523de930580bd60319c2802d3dbfce9aeaa7c778116c?d=mp&s=160"},"body":"Hi Shawn,\n\nThat's OK, but I want to backup my git repo locally because I don't\nhave another remote git server. Can you modify your post-commit code\nto backup the repo to /backups/git folder instead of using another\nexternal git repo?\n\nthanks in advance.\nregards\nIsrael.\n\nOn 10/12/09, Shawn O. Pearce <spearce@spearce.org> wrote:\n> Israel Garcia <igalvarez@gmail.com> wrote:\n>> Which is the simplest  way to backup a git repository after every commit?\n>\n> Add a commit hook to push to another location, e.g.:\n>\n>   git remote add --mirror backup you@another.host:path/to/backup.git\n>\n>   cat >.git/hooks/post-commit\n>   #!/bin/sh\n>   git push backup\n>   ^D\n>\n>   chmod a+x .git/hooks/post-commit\n>\n> --\n> Shawn.\n>\n\n\n-- \nRegards;\nIsrael Garcia\n"},{"id":"124707","messageId":"20091012143043.GJ9261@spearce.org","threadId":"21212","inReplyTo":"194a2c240910120725u72cdb588p3c66bc730e6953d@mail.gmail.com","subject":"Re: backup git repo on every commit","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-10-12T14:30:43Z","receivedAt":"2009-10-12T14:30:43Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Israel Garcia <igalvarez@gmail.com> wrote:\n> That's OK, but I want to backup my git repo locally \n\nJust change the path of the backup remote (that final argument to\ngit remote add) to point to the local directory.\n\nThough I guess you would also need to run git init there, e.g.:\n\n  git --git-dir=/backup/project.git init\n  git remote add --mirror backup /backup/project.git\n\n  # and create the hook as below\n\nOf course, backup to another folder on the same disk isn't a backup\nat all, the disk can still fail and lose both repositories.\n\n> On 10/12/09, Shawn O. Pearce <spearce@spearce.org> wrote:\n> > Israel Garcia <igalvarez@gmail.com> wrote:\n> >> Which is the simplest  way to backup a git repository after every commit?\n> >\n> > Add a commit hook to push to another location, e.g.:\n> >\n> >   git remote add --mirror backup you@another.host:path/to/backup.git\n> >\n> >   cat >.git/hooks/post-commit\n> >   #!/bin/sh\n> >   git push backup\n> >   ^D\n> >\n> >   chmod a+x .git/hooks/post-commit\n\n-- \nShawn.\n"},{"id":"124705","messageId":"194a2c240910120739j58cc1ec0o629b0df7d31e3fdd@mail.gmail.com","threadId":"21212","inReplyTo":"20091012143043.GJ9261@spearce.org","subject":"Re: backup git repo on every commit","fromName":"Israel Garcia","fromEmail":"igalvarez@gmail.com","sentAt":"2009-10-12T14:39:24Z","receivedAt":"2009-10-12T14:39:24Z","isPatch":false,"sender":{"key":"igalvarez@gmail.com","avatar":"https://gravatar.com/avatar/8ccdadcbfb98c0cb0940523de930580bd60319c2802d3dbfce9aeaa7c778116c?d=mp&s=160"},"body":"On 10/12/09, Shawn O. Pearce <spearce@spearce.org> wrote:\n> Israel Garcia <igalvarez@gmail.com> wrote:\n>> That's OK, but I want to backup my git repo locally\n>\n> Just change the path of the backup remote (that final argument to\n> git remote add) to point to the local directory.\n>\n> Though I guess you would also need to run git init there, e.g.:\n>\n>   git --git-dir=/backup/project.git init\n>   git remote add --mirror backup /backup/project.git\n>\n>   # and create the hook as below\nNice..:-)\n\n>\n> Of course, backup to another folder on the same disk isn't a backup\n> at all, the disk can still fail and lose both repositories.\nYeap, but I use rsync to backup /backup folder on a remote server\nevery night. /backup folder other apps backups.\n\nthanks Shawn.\n\nregards\n\nIsrael.\n\n>\n>> On 10/12/09, Shawn O. Pearce <spearce@spearce.org> wrote:\n>> > Israel Garcia <igalvarez@gmail.com> wrote:\n>> >> Which is the simplest  way to backup a git repository after every\n>> >> commit?\n>> >\n>> > Add a commit hook to push to another location, e.g.:\n>> >\n>> >   git remote add --mirror backup you@another.host:path/to/backup.git\n>> >\n>> >   cat >.git/hooks/post-commit\n>> >   #!/bin/sh\n>> >   git push backup\n>> >   ^D\n>> >\n>> >   chmod a+x .git/hooks/post-commit\n>\n> --\n> Shawn.\n>\n\n\n-- \nRegards;\nIsrael Garcia\n"},{"id":"124731","messageId":"20091012183504.GA3872@mrslave","threadId":"21212","inReplyTo":"20091012141544.GF9261@spearce.org","subject":"Re: backup git repo on every commit","fromName":"Christian Himpel","fromEmail":"chressie@googlemail.com","sentAt":"2009-10-12T18:35:04Z","receivedAt":"2009-10-12T18:35:04Z","isPatch":false,"sender":{"key":"chressie@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/227883?v=4"},"body":"On Mon, Oct 12, 2009 at 07:15:44AM -0700, Shawn O. Pearce wrote:\n> Israel Garcia <igalvarez@gmail.com> wrote:\n>   git remote add --mirror backup you@another.host:path/to/backup.git\n> \n>   cat >.git/hooks/post-commit\n>   #!/bin/sh\n>   git push backup\n>   ^D\n> \n>   chmod a+x .git/hooks/post-commit\n\nSince this is meant as a backup, is there also a sane way to push the\nreflog entries as well?  Or is it okay just to copy .git/logs to the\nbackup repository?\n\nThanks,\nchressie\n"},{"id":"124734","messageId":"20091012183754.GP9261@spearce.org","threadId":"21212","inReplyTo":"20091012183504.GA3872@mrslave","subject":"Re: backup git repo on every commit","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-10-12T18:37:54Z","receivedAt":"2009-10-12T18:37:54Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Christian Himpel <chressie@googlemail.com> wrote:\n> Since this is meant as a backup, is there also a sane way to push the\n> reflog entries as well?  Or is it okay just to copy .git/logs to the\n> backup repository?\n\nThere isn't a way to transfer reflogs, but one could rsync them\nover to the backup.  Some records might be missing their SHA-1 in\nthe backup if that particular object wasn't pushed there, but the\nreflog code is generally tolerant of those garbage records.\n\n-- \nShawn.\n"},{"id":"124852","messageId":"194a2c240910130943j40c12902o760e463e7a8ce8fa@mail.gmail.com","threadId":"21212","inReplyTo":"20091012143043.GJ9261@spearce.org","subject":"Re: backup git repo on every commit","fromName":"Israel Garcia","fromEmail":"igalvarez@gmail.com","sentAt":"2009-10-13T16:43:51Z","receivedAt":"2009-10-13T16:43:51Z","isPatch":false,"sender":{"key":"igalvarez@gmail.com","avatar":"https://gravatar.com/avatar/8ccdadcbfb98c0cb0940523de930580bd60319c2802d3dbfce9aeaa7c778116c?d=mp&s=160"},"body":"Hi Shawn,\n\nSorry to ask again, but I'm a little confuse about how git work in my case.\nI use gitosis on a server where I have all repos\n(/usr/local/git/repositories/), so different people clone their repos\non their computers. What I want is to backup, on gitosis server, all\nrepos in /backups/git/repositories/ after every commit. So, my\nquestions are:\n\nDo I have to run these two comands on tha gitosis server? Or on a\nremote computer?\n  git --git-dir=/backup/project.git init\n  git remote add --mirror backup /backup/project.git\n\nThe post-commit are execute on gitosis server or on the remote pc?\n\nI'm completely new using git so I'm a little confuse.. sorry for asking again.\n\nthanks a lot.\nregards\nIsrael.\nOn 10/12/09, Shawn O. Pearce <spearce@spearce.org> wrote:\n> Israel Garcia <igalvarez@gmail.com> wrote:\n>> That's OK, but I want to backup my git repo locally\n>\n> Just change the path of the backup remote (that final argument to\n> git remote add) to point to the local directory.\n>\n> Though I guess you would also need to run git init there, e.g.:\n>\n>   git --git-dir=/backup/project.git init\n>   git remote add --mirror backup /backup/project.git\n>\n>   # and create the hook as below\n>\n> Of course, backup to another folder on the same disk isn't a backup\n> at all, the disk can still fail and lose both repositories.\n>\n>> On 10/12/09, Shawn O. Pearce <spearce@spearce.org> wrote:\n>> > Israel Garcia <igalvarez@gmail.com> wrote:\n>> >> Which is the simplest  way to backup a git repository after every\n>> >> commit?\n>> >\n>> > Add a commit hook to push to another location, e.g.:\n>> >\n>> >   git remote add --mirror backup you@another.host:path/to/backup.git\n>> >\n>> >   cat >.git/hooks/post-commit\n>> >   #!/bin/sh\n>> >   git push backup\n>> >   ^D\n>> >\n>> >   chmod a+x .git/hooks/post-commit\n>\n> --\n> Shawn.\n>\n\n\n-- \nRegards;\nIsrael Garcia\n"},{"id":"124854","messageId":"20091013174913.GV9261@spearce.org","threadId":"21212","inReplyTo":"194a2c240910130943j40c12902o760e463e7a8ce8fa@mail.gmail.com","subject":"Re: backup git repo on every commit","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-10-13T17:49:13Z","receivedAt":"2009-10-13T17:49:13Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Israel Garcia <igalvarez@gmail.com> wrote:\n> Sorry to ask again, but I'm a little confuse about how git work in my case.\n> I use gitosis on a server where I have all repos\n> (/usr/local/git/repositories/), so different people clone their repos\n> on their computers. What I want is to backup, on gitosis server, all\n> repos in /backups/git/repositories/ after every commit. So, my\n> questions are:\n> \n> Do I have to run these two comands on tha gitosis server?\n\nYes.\n\n> The post-commit are execute on gitosis server or on the remote pc?\n\nActually, you need the post-update hook.  post-commit doesn't run\non the gitosis server.\n\nI suggested post-commit because I thought you were talking about\nbacking up your local working directory each time you called\n\"git commit\".  But since you are actually backing up every\n\"git push\" you need to use the hooks invoked by that instead.\n \n-- \nShawn.\n"},{"id":"124858","messageId":"194a2c240910131108h10acbacdy68306c9c3389517@mail.gmail.com","threadId":"21212","inReplyTo":"20091013174913.GV9261@spearce.org","subject":"Re: backup git repo on every commit","fromName":"Israel Garcia","fromEmail":"igalvarez@gmail.com","sentAt":"2009-10-13T18:08:16Z","receivedAt":"2009-10-13T18:08:16Z","isPatch":false,"sender":{"key":"igalvarez@gmail.com","avatar":"https://gravatar.com/avatar/8ccdadcbfb98c0cb0940523de930580bd60319c2802d3dbfce9aeaa7c778116c?d=mp&s=160"},"body":"On 10/13/09, Shawn O. Pearce <spearce@spearce.org> wrote:\n> Israel Garcia <igalvarez@gmail.com> wrote:\n>> Sorry to ask again, but I'm a little confuse about how git work in my\n>> case.\n>> I use gitosis on a server where I have all repos\n>> (/usr/local/git/repositories/), so different people clone their repos\n>> on their computers. What I want is to backup, on gitosis server, all\n>> repos in /backups/git/repositories/ after every commit. So, my\n>> questions are:\n>>\n>> Do I have to run these two comands on tha gitosis server?\n>\n> Yes.\n>\n>> The post-commit are execute on gitosis server or on the remote pc?\n>\n> Actually, you need the post-update hook.  post-commit doesn't run\n> on the gitosis server.\n>\n> I suggested post-commit because I thought you were talking about\n> backing up your local working directory each time you called\n> \"git commit\".  But since you are actually backing up every\n> \"git push\" you need to use the hooks invoked by that instead.\nHi Shawn,\n\nThanks for your answer,  could you please put here how you think\npost-update file should be setup? Remember in my case I want to backup\nevery repo to /backups/git folder for example.\n\nThanks in advance.\nregrads\n\nIsrael.\n>\n> --\n> Shawn.\n>\n\n\n-- \nRegards;\nIsrael Garcia\n"},{"id":"124860","messageId":"194a2c240910131114q19b6c822t5806d20005341cb4@mail.gmail.com","threadId":"21212","inReplyTo":"20091013174913.GV9261@spearce.org","subject":"Re: backup git repo on every commit","fromName":"Israel Garcia","fromEmail":"igalvarez@gmail.com","sentAt":"2009-10-13T18:14:16Z","receivedAt":"2009-10-13T18:14:16Z","isPatch":false,"sender":{"key":"igalvarez@gmail.com","avatar":"https://gravatar.com/avatar/8ccdadcbfb98c0cb0940523de930580bd60319c2802d3dbfce9aeaa7c778116c?d=mp&s=160"},"body":"BTW, is there any git-dump or git-backup command to do some kind of\nbackup I'm looking for?\n\nregards,\n\nIsrael.\n\nOn 10/13/09, Shawn O. Pearce <spearce@spearce.org> wrote:\n> Israel Garcia <igalvarez@gmail.com> wrote:\n>> Sorry to ask again, but I'm a little confuse about how git work in my\n>> case.\n>> I use gitosis on a server where I have all repos\n>> (/usr/local/git/repositories/), so different people clone their repos\n>> on their computers. What I want is to backup, on gitosis server, all\n>> repos in /backups/git/repositories/ after every commit. So, my\n>> questions are:\n>>\n>> Do I have to run these two comands on tha gitosis server?\n>\n> Yes.\n>\n>> The post-commit are execute on gitosis server or on the remote pc?\n>\n> Actually, you need the post-update hook.  post-commit doesn't run\n> on the gitosis server.\n>\n> I suggested post-commit because I thought you were talking about\n> backing up your local working directory each time you called\n> \"git commit\".  But since you are actually backing up every\n> \"git push\" you need to use the hooks invoked by that instead.\n>\n> --\n> Shawn.\n>\n\n\n-- \nRegards;\nIsrael Garcia\n"},{"id":"124862","messageId":"20091013181813.GY9261@spearce.org","threadId":"21212","inReplyTo":"194a2c240910131114q19b6c822t5806d20005341cb4@mail.gmail.com","subject":"Re: backup git repo on every commit","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-10-13T18:18:13Z","receivedAt":"2009-10-13T18:18:13Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Israel Garcia <igalvarez@gmail.com> wrote:\n> BTW, is there any git-dump or git-backup command to do some kind of\n> backup I'm looking for?\n\nNo, you backup git by making a clone.  E.g. `git clone --bare`.\nSince this leaves you with a directory, you need to then perhaps\nuse some sort of file combiner tool like tar or zip to produce a\nsingle file for backup to tape.\n\nYou can incrementally update that backup clone using git push to\nwrite into it, or you can just blow it away and recreate it each\ntime you make a backup.\n\nOne could also use `git bundle` to create backup file that had\neverything packaged in one neat file, but this can be slightly\nharder to work with since a bundle is not a git repository.\n \n-- \nShawn.\n"},{"id":"124857","messageId":"20091013181843.GZ9261@spearce.org","threadId":"21212","inReplyTo":"194a2c240910131108h10acbacdy68306c9c3389517@mail.gmail.com","subject":"Re: backup git repo on every commit","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-10-13T18:18:43Z","receivedAt":"2009-10-13T18:18:43Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Israel Garcia <igalvarez@gmail.com> wrote:\n> Thanks for your answer,  could you please put here how you think\n> post-update file should be setup? Remember in my case I want to backup\n> every repo to /backups/git folder for example.\n\nExactly the same as that post-commit I mentioned, just call the\nfile .git/hooks/post-update instead.\n\n-- \nShawn.\n"}]}