I am moving some svn repositories to Git. So, what I basically try to do is this:
The general idea would be to:
There are other techniques back in 2008, based on gibak, but the idea remains the same.
Example of a post-receive hook:
#!/bin/sh
#
# A hook script that is called after a successful
# commit is made.
#
# Place this file in .git/hooks and chmod +x
BRANCH=`git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
git push origin $BRANCH
#!/usr/bin/env ruby
STDIN.read.split("\n").each do |line|
oldrev, newrev, refname = line.split(' ')
if refname.match(/^refs\/heads\/(.*)/)
branch = $1
`git push origin #{branch}`
else
puts "#{refname} was weird, not sure what to do."
end
end
Doesn't seem like there's anything special here -- you just need a standard backup solution.
I've had good luck with rsnapshot, or rsync if I just need simple backups.